...
whatis command - displays a one-line summary about command
man command - displays on-line manual pages about command
'man' can be use on almost all of the shell commands listed below to get the complete description of the command.
Shell commands are case sensitive
...
grep search-string filename(s) : to find and type out lines containing the string in a file
Most useful search options:
-i : case insensitive search
-w : whole words only
-v : invert match; type out lines that do NOT contain the string (invert the search)
-c : count the number of lines that contain a match
Search for files & directories
find pathname directory-name search-string [-name (part_of_)name]
Useful for finding particular files or directories. 'find' descends the directory tree beginning at each pathname directory-name and locates files/directories that meet the specified conditions. Wild cards can be used in the search string.
find search criteria
'find' is a very powerful and useful command. Use 'man find' to find out more.It can for example also be used in combination with 'grep':
$
Most useful search options:
-name ... | search for files/directories with a certain name or part of name. Wildcards can be used. |
-type ... | search for certain files types only. 'd' → directories; 'f' → files; 'l' → symbolic links |
-exec ... | execute the following command on each found file/directory. '{}' serves as placeholder for found files/directories needs to get terminated with '\;' |
For example, it can be used in combination with 'grep':
find . -name '*.scr' find . -name '*.sh' -exec grep case {} \;
The above command will print all lines containing the word 'case' of files with end on '.scrsh'.
Counting words/lines/characters in a file
wc filename(s) : counts the number of words, lines, and characters in a file
Options
Most useful search options:
-l : count lines lines
-c : count characters characters
-w : count words words
Pipe
| : (pipe) redirect standard output of first command to standard input of second command
Example:
$ ls -1 | wc -l : count the number of files in a directory
Compare files
difffilename1 filename2 : compares contents of two files on a line-by-line basis
xxdiff filename1 filename2 [filename3] : graphically compares contents of two or three files on a line-by-line basis. Can also be used to edit files!
xxdiff directory1 directory2 : graphically compares contents of two directories
xxdiff can also be used to edit files!
tkdifffilename1 filename2 : graphically compares contents of two files on a line-by-line basis. Use on guillimin onstead of 'xxdiff'.
File Transfer
File Transfer
While 'cp' can only be used to copy files and directories on the same machine, there are tools that can copy files and directories from one machine to another.
rsync : which stands for remote sync, is a remote and local file synchronization tool. a rsync : a fast, versatile, remote (and local) file/directory-copying tool
Usage:
rsync origin destination
rsync user@origin_machine:origin destination
rsync origin user@destination_machine:destination
origin and destination can be file(s) and/or directories.
Only the origin or the destination machine can be a nother machine, not both.
Options:
...