The "Linux questions (and other stuff)" thread


  1. EarlyMon

    EarlyMon The PearlyMon Moderator

    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.
    MoodyBlues likes this.
  2. saptech

    saptech Well-Known Member

    9to5cynic likes this.
  3. Dngrsone

    Dngrsone Well-Known Member

    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.
  4. saptech

    saptech Well-Known Member

    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)!
    Dngrsone likes this.
  5. Dngrsone

    Dngrsone Well-Known Member

    What's the default desktop environment for Debian?
  6. MoodyBlues

    MoodyBlues - Crazy peacock person - Guide

    Wow. I did not know this.
  7. MoodyBlues

    MoodyBlues - Crazy peacock person - Guide

    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.
  8. Joelgp83

    Joelgp83 Well-Known Member

    I'd suspect it was something gnome 2 or 3 based....
  9. palmtree5

    palmtree5 Sunny Vacation Supporter! Moderator

    Not really unless I push it to the upcoming weekend as I have more important things to do between now and Friday
  10. MoodyBlues

    MoodyBlues - Crazy peacock person - Guide

    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. :)
    EarlyMon likes this.
  11. EarlyMon

    EarlyMon The PearlyMon Moderator

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

    palmtree5 Sunny Vacation Supporter! Moderator

    Apparently not. What Moody posted works :)
  13. MoodyBlues

    MoodyBlues - Crazy peacock person - Guide

    No, the basename line is taking care of that.
  14. saptech

    saptech Well-Known Member

    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.
    Dngrsone likes this.
  15. MoodyBlues

    MoodyBlues - Crazy peacock person - Guide

    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)
  16. palmtree5

    palmtree5 Sunny Vacation Supporter! Moderator

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

    Dngrsone Well-Known Member

    Unity is not exclusive to Ubuntu... one should be able to install it on Debian.
    palmtree5 likes this.
  18. MoodyBlues

    MoodyBlues - Crazy peacock person - Guide

    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!)
  19. EarlyMon

    EarlyMon The PearlyMon Moderator

    The last SUBDIR2 in the zip command isn't affected by the basename.

    Interesting. I'm guessing that the IFS sorted that as well...
    MoodyBlues likes this.
  20. jonbanjo

    jonbanjo Well-Known Member

    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");
    }
    ?>
    EarlyMon likes this.
  21. palmtree5

    palmtree5 Sunny Vacation Supporter! Moderator

    There are other shells...
  22. jonbanjo

    jonbanjo Well-Known Member

    csh looks nicer to me but (at least for my own use). I don't see the point of using a shell for the sake of maybe doing the right thing.
  23. EarlyMon

    EarlyMon The PearlyMon Moderator

    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
  24. MoodyBlues

    MoodyBlues - Crazy peacock person - Guide

    You're right. My quick glance at that line shouldn't have been so quick. :D

    Yes, that's it.
  25. MoodyBlues

    MoodyBlues - Crazy peacock person - Guide

    I'd throw grep in there, too.
    EarlyMon likes this.

Share This Page