Tag: coreutils

  • sort – sort lines of text files

    $cat test.txt sept aug jan dec oct apr feb mar11 mar1 $sort test.txt apr aug dec feb jan mar1 mar11 oct sept $sort -M test.txt jan feb mar1 mar11 apr aug sept oct dec $

  • basename – strip directory and suffix from filenames

    A UNIX Command $basename basename: missing operand Try `basename –help’ for more information. $basename /usr/bin/ bin $basename /usr/ usr $ $basename /usr/bin/less less $basename /usr/include/ma malloc.h math.h $basename /usr/include/math.h math.h $basename /usr/include/math.h . math.h $basename /usr/include/math.h .h math $basename /usr/lib/libgccpp.so.1 libgccpp.so.1 $basename /usr/lib/libgccpp.so.1 .1 libgccpp.so $ UNIX Explanation `basename’ removes any leading directory components from […]

  • truncate – shrink or extend the size of a file to the specified size

    A UNIX Command $cat example.text hello $ls -l example.text -rw-r–r– 1 jeffrin jeffrin 6 Jun 21 02:32 example.text $truncate -s 10 example.text $ls -l example.text -rw-r–r– 1 jeffrin jeffrin 10 Jun 21 02:35 example.text $hexdump example.text 0000000 6568 6c6c 0a6f 0000 0000 000000a $cat example.text hello $truncate -s 9 example.text $ls -l example.text -rw-r–r– 1 […]

  • touch -c behaves incorrectly (non-POSIX)

    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439033 POSIX says about ‘touch'[*]: -c Do not create a specified file if it does not exist. Do not write any diagnostic messages concerning this condition. [*] http://www.opengroup.org/onlinepubs/009695399/utilities/touch.html But under some conditions, ‘touch’ writes a diagnostic message when the file doesn’t exist. For instance: vin:~> mkdir dir vin:~> chmod 000 dir vin:~> /usr/bin/touch -c dir/file […]

  • coreutils: ls –quoting-style=c and | (pipe) symbol

    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=432945 output of ls –quoting-style=c is incorrect when filename contains | (pipe) symbol. Steps: mkdir /tmp/bla touch “/tmp/bla/filename with | pipe” ls –quoting-style=c /tmp/bla returns: “filename with \| pipe” thanks, -Mathieu Ref: http://groups.google.com/group/comp.lang.c/browse_thread/thread/0db8070def6a4453

  • coreutils: join outputs wrong field order for -v option

    join – join lines of two files on a common field http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=410270 Package: coreutils Version: 5.97-5 Severity: normal the join field is incorrect for the -v version. #08-Thu-20-03-40 /tmp$ cat>|a #a1,a2,c3,a4,a5 #a21,a22,a33,a44,a55 #08-Thu-20-05-07 /tmp$ cat>|b #b1,b2,b3,c3,b5 #b21,b22,b33,b44,b55 #08-Thu-20-06-07 /tmp$ join -t, -i -1 3 -2 4 a b #c3,a1,a2,a4,a5,b1,b2,b3,b5 #08-Thu-20-06-10 /tmp$ join -v 2 -t, […]

  • comm – compare two sorted files line by line

    $comm sorta.txt sortb.txt d g comm: file 1 is not in sorted order e s x comm: file 2 is not in sorted order g s n $cat sorta.txt d g e s $cat sortb.txt x g s n $ $cat sorta.txt a b c d $cat sortb.txt a f g h $comm sorta.txt sortb.txt […]

  • nl – number lines of files

    $cat workethics.txt Work ethics in QA Fashion $nl workethics.txt > newfile $cat new new newfile $cat newfile 1 Work 2 ethics 3 in 4 QA 5 Fashion $ nl – number lines of files Write each FILE to standard output, with line numbers added. With no FILE, or when FILE is -, read standard input. […]

  • shuf – generate random permutations.

    $cat workethics.txt Work ethics in QA Fashion $shuf workethics.txt Work Fashion in QA ethics $shuf workethics.txt ethics QA in Fashion Work $ shuf – generate random permutations. Write a random permutation of the input lines to standard output. Reference/Source : Debian Manual for “shuf”.

  • fold — wrapping

    $fold -w 3 what is your name wha t i s y our na me $fold -b 3 fold: 3: No such file or directory $fold -b3 what is your name wha t i s y our na me $fold -s3 what is your name wha t is you r nam e $ fold – […]