Using grep for multiple search patterns

grep -e ‘attrib1’ -e ‘attrib3’ file From the man page : -e PATTERN, –regexp=PATTERN Use PATTERN as the pattern. This can be used to specify multiple search patterns, or to protect a pattern beginning with a hyphen (-). (-e is specified by POSIX.) Edit : Alternatively , you can save patterns in a file and … Read more

unix command line execute with . (dot) vs. without

. name sources the file called name into the current shell. So if a file contains this A=hello Then if you sources that, afterwards you can refer to a variable called A which will contain hello. But if you execute the file (given proper execution rights and #!/interpreterline), then such things won’t work, since the … Read more

Unix:merge multiple CSV files with same header by keeping the header of the first file

awk ‘FNR==1 && NR!=1{next;}{print}’ *.csv tested on solaris unix: > cat file1.csv Id,city,name ,location 1,NA,JACK,CA > > cat file2.csv ID,city,name,location 2,NY,JERRY,NY > > nawk ‘FNR==1 && NR!=1{next;}{print}’ *.csv Id,city,name ,location 1,NA,JACK,CA 2,NY,JERRY,NY > Explanation given by kevin-d: FNR is the number of lines (records) read so far in the current file. NR is the number … Read more

What is special about /dev/tty? [closed]

The ‘c’ means it’s a character device. tty is a special file representing the ‘controlling terminal’ for the current process. Character Devices Unix supports ‘device files’, which aren’t really files at all, but file-like access points to hardware devices. A ‘character’ device is one which is interfaced byte-by-byte (as opposed to buffered IO). TTY /dev/tty … Read more