8/06/2018

Adding .list to all file in one folder

Adding ".list" to all file in one folder

rename 's/$/.list/g' *

If you would like to add prefix, here is the command:

rename 's/^/pre_/g' *

7/26/2018

Read file multiple times

foreach()
        {
            ($tape_in,$min,$max) =split();
         
            if($sw >= $min &&  $sw<=$max)
            {
              $input_tape=$tape_in; 
            }

        }
       seek INPUT, 0, 0;

sed print lines between patterns

$ seq 1 100 > test
$ sed -n '/^12$/,/^15$/p' test
12
13
14
15

https://unix.stackexchange.com/questions/264962/print-lines-of-a-file-between-two-matching-patterns

7/13/2018

Find difference between two large files

sort file1 file2 | uniq -u > file3
If you want to see just the duplicate entries use "uniq -d" option:
sort file1 file2 | uniq -d > file3

From:
https://stackoverflow.com/questions/18069611/fastest-way-of-finding-differences-between-two-files-in-unix

4/23/2018

perl print double digit

$tapenum= sprintf("%02d",$tapenum);

4/17/2018

AWK using file separator

c tmp.list | awk '{print $7}' | awk 'BEGIN { FS = "/" } ; { print substr($8,0,34) }' >tmp2.list