Berkeley CSUA MOTD:Entry 34742
Berkeley CSUA MOTD
2018/07/17 [General] UID:1000 Activity:popular

2004/11/8-9 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:34742 Activity:low
11/7    Is there a shell command that will unsort (randomize) a file,
        like the way sort does on a line-by-line basis?  I don't need any
        mathematical randomizing, just want to mix up my input lines
        occasionally. tia.
        \_ ~mconst/bin/shuffle
        \_ i have some short code to do this. if the file is "large" [+32k ll]
           it's somewhat tricky to do ... need a good random generator.
           like perl's default doenst have enough seed values. why do
           people ask stuff like this anonymously? --psb
           \- this looks really slow to me:
              /bin/time  ./ < /tmp/infile > /dev/null
              real       46.9
              /bin/time ./ < /tmp/infile > /dev/null
              real        4.3
              \_ What do you expect?  One's an algorithm, one's a one line
        \_ my stupid shell script that works fine for small files:
           awk 'BEGIN { srand() }{ print rand(),$0 }' $1 \
             |sort|sed 's/^[^ ]* //'
             \-I dont think this is portable to "classic awk" ... but
               gawk is probably good enough. --psb
               \- btw, i just stumbled, er shuffled, on to:
                  perldoc -q shuffle  --psb
2018/07/17 [General] UID:1000 Activity:popular

You may also be interested in these entries...
2012/8/30-11/7 [Computer/SW/Unix, Computer/SW/Apps] UID:54470 Activity:nil
8/30    Is wall just dead? The wallall command dies for me, muttering
        something about /var/wall/ttys not existing.
        \_ its seen a great drop in usage, though it seems mostly functional.
        \_ Couldn't open wall log!: Bad file descriptor
           Could not open wall subscription directory /var/wall/ttys: No such file or directory
2012/9/20-11/7 [Finance/Investment, Computer/SW/Unix] UID:54482 Activity:nil
9/20    How do I change my shell? chsh says "Cannot change ID to root."
        \_ /usr/bin/chsh does not have the SUID permission set. Without
           being set, it does not successfully change a user's shell.
           Typical newbie sys admin (on soda)
           \_ Actually, it does: -rwsr-xr-x 1 root root 37552 Feb 15  2011 /usr/bin/chsh
2012/9/24-11/7 [Computer/SW/Languages, Computer/SW/Unix] UID:54484 Activity:nil
9/24    How come changing my shell using ldapmodify (chsh doesn't work) doesn't
        work either? ldapsearch and getent show the new shell but I still get
        the old shell on login.
        \_ Scratch that, it magically took my new shell now. WTF?
           \_ probably nscd(8)
2012/4/27-6/4 [Computer/SW/Languages/Misc, Computer/SW/Unix] UID:54372 Activity:nil
4/27    I wrote a little shell script to collect iostat data:
        DATE=`date +%m%d`
        while true
2011/11/20-2012/2/6 [Computer/SW/Unix, Computer/Companies/Apple] UID:54237 Activity:nil
11/20   Are there tools that can justify a chunk of plain ASCII text by
        replacing words with words of similar meaning and inserting/removing
        commas into the text?  I received a 40-line plain text mail where
        all the lines are justified on left and right.  Every word and comma
        is followed by only one space, and every period is followed by two
        spaces.  The guy is my kid's karate instructor which I don't think is
2011/10/26-12/6 [Computer/SW/Unix] UID:54202 Activity:nil
10/24  What's an easy way to see if say column 3 of a file matches a list of
       expressions in a file? Basically I want to combine "grep -f <file>"
       to store the patterns and awk's $3 ~ /(AAA|BBB|CCC)/ ... I realize
       I can do this with "egrep -f " and use regexp instead of strings, but
       was wondering if there was some magic way to do this.
       \_ UNIX has no magic. Make a shell script to produce the ask or egrep