• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

The "Linux questions (and other stuff)" thread

Hint -

Code:
# Change input field separator from default space, restore when done

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

for SUBDIR in `ls -d1 */`
do
  echo "Testing: $SUBDIR"
done

# cleanup

IFS=$SAVEIFS
Kinda in a hurry, saw this on a drive-by, sorry it's not complete.

Probably use sed to fix whatever else within the for loop.
 
I didn't know Mint was at the top.

Now I wonder if I should be proud that my OS of choice is the most popular or if maybe I should be bucking the trend and using something that isn't quite so mainstream.

I could go back to Slackware, try Arch, or something.

I see DSL is finally looking at an update after four years of no movement...

I always did like the early fluxbox interface of DSL.
 
Yes, Mint has been on top for a good while. It's based on Ubuntu which is based on Debian, so the top three are Debian based. If you want to try something different, give Debian a try. I've always used it instead of its siblings. Slackware & Arch are good choices also, along with Mageia (mga)!
 
Using EM's snippet, I've got it working, but I wonder if you'd like to take a stab at it before I post. Let me know.

Not really unless I push it to the upcoming weekend as I have more important things to do between now and Friday
 
Not really unless I push it to the upcoming weekend as I have more important things to do between now and Friday
Okay, here's my script:

[high]
#!/bin/bash
SUBDIR=$1
SAVEIFS=$IFS

IFS=$(echo -en "\n\b")
cd $SUBDIR

for SUBDIR2 in `ls -d1 */`
do ZIPFILE=$(basename "$SUBDIR2")
zip -r $ZIPFILE/$ZIPFILE.zip $SUBDIR2
done

# cleanup
IFS=$SAVEIFS
[/high]

As always, this can be tweaked as needed/desired. Right now, it's taking you to the directory whose name you enter at runtime, then it's doing its thing as far as locating subdirectories and zipping their contents. It's creating the zipped files in each subdirectory; of course that can be changed to wherever you'd prefer.

And thanks to EM for the $IFS idea. :)
 
Okay, here's my script:

[high]
#!/bin/bash
SUBDIR=$1
SAVEIFS=$IFS

IFS=$(echo -en "\n\b")
cd $SUBDIR

for SUBDIR2 in `ls -d1 */`
do ZIPFILE=$(basename "$SUBDIR2")
zip -r $ZIPFILE/$ZIPFILE.zip $SUBDIR2
done

# cleanup
IFS=$SAVEIFS
[/high]

As always, this can be tweaked as needed/desired. Right now, it's taking you to the directory whose name you enter at runtime, then it's doing its thing as far as locating subdirectories and zipping their contents. It's creating the zipped files in each subdirectory; of course that can be changed to wherever you'd prefer.

And thanks to EM for the $IFS idea. :)

Don't have to pump those through sed to escape any blanks in the path name?

Apparently not. What Moody posted works :)
 
What's the default desktop environment for Debian?
It used to be Gnome 2, but assume it may be Gnome 3. I haven't installed a default Debian in very long time.

I'm not running it at the moment but when I did, I would do a minimum install of the basic system and then add other components as I needed them. Such as a WM instead of DE.
 
What about Unity? Or is that strictly a *buntu thing? (I stick to my trusty and beloved KDE, so I'm quite out of the loop on those other DEs. :D)

Unity is the default on Ubuntu (I wouldn't say strictly though as it can be installed on non-*buntu distros)
 
Unity is the default on Ubuntu (I wouldn't say strictly though as it can be installed on non-*buntu distros)

Unity is not exclusive to Ubuntu... one should be able to install it on Debian.
Thanks for the info. Now I guess the question is, WHY would anyone want to install it?! :laugh: (Yes, I'm a KDE person through and through--but I did try Unity (just for the hell of it) a few times, so at least I'm not insulting something I've never tried!)
 
I don't get on well with bash (I dislike the syntax and there seems to me to be a number of "gotchas"). I guess if I had ambitions of being a system admin I'd have to change my ways but for me at home, I'd probably do something like.

PHP:
<?php
if (count ($argv) !=2){
  echo "Usage zip.php directory\n";
  exit;
}

if (!@chdir($argv[1])){
  echo "Invalid directory\n";
  exit;
}

$logfile = "zip.log";
@unlink($logfile);
foreach (glob("*", GLOB_ONLYDIR | GLOB_MARK) as $dir){
  $name = basename($dir);
  exec("zip -r \"$dir$name.zip\" \"$dir\" &>>$logfile");
}
?>
 
I don't get on well with bash (I dislike the syntax and there seems to me to be a number of "gotchas"). I guess if I had ambitions of being a system admin I'd have to change my ways but for me at home, I'd probably do something like.

PHP:
<?php
if (count ($argv) !=2){
  echo "Usage zip.php directory\n";
  exit;
}

if (!@chdir($argv[1])){
  echo "Invalid directory\n";
  exit;
}

$logfile = "zip.log";
@unlink($logfile);
foreach (glob("*", GLOB_ONLYDIR | GLOB_MARK) as $dir){
  $name = basename($dir);
  exec("zip -r \"$dir$name.zip\" \"$dir\" &>>$logfile");
}
?>

There are other shells...
 
Shell + sed + awk and you can do nearly anything.

Lot of scripting languages came later to help those finding that path too difficult.

I once took weeks and found a way to pass variables by reference in csh, something that is known undoable, just because.

And bash is a hippie's approach to ksh. :D
 
Back
Top Bottom