Showing posts with label grep. Show all posts
Showing posts with label grep. Show all posts

Wednesday, March 30, 2011

Miscellaneous Unix Commands

type two commands at a timecmd1 ; cmd2
spell check a filecat filename | spell
Reset terminal: if mistakenly viewed a binary file with catstty sane
append results of a command onto an existing filecmd>>file.ext
write results of a command to a filecmd>file.ext
logout[Ctrl]+D or exit
ftp file to host1 from host2 ftp host1
search files for a string
-# = display '#' lines on both sides
-c = display a count
-v = display non-matching lines
-i = ignore case
grep string filename

System Information

list current shellecho $SHELL
show your groupgrep yourid /etc/passwd
show all groupsmore /etc/group
system informationuname -a
who's logged infinger

Monday, March 21, 2011

Grep

match any character.grep l..n filenamefinds 'lynn' or 'loan'
match only if at the beginning of a line^grep ^day filenamefinds 'day into night'but not 'Some day'
match only if at the end of the line$grep day$ filenamefinds 'One fine day'but not 'Monday is good'
search for '.' or '^' or '$' in a file\grep \* filenamefinds '*****1.05'
search for a set of names[]grep [dog,dil]bert filenamefinds 'dogbert' and 'dilbert'
find all lines that start with an alphabetic character in upper or lower case^[]grep ^[A-Z,a-z] filename