Difference between revisions of "Linux"
From kemiko
Line 1: | Line 1: | ||
<strong>Favorite Commands:</strong> | <strong>Favorite Commands:</strong> | ||
+ | |||
+ | Some variables: | ||
+ | FILE: a filename | ||
+ | PATH: a directory/file path | ||
+ | LINE: a line's contents | ||
+ | COMMANDS: a/many commands like awk, cat, echo, grep, etc. | ||
+ | LITERAL: a literal/static variable no REGEX | ||
+ | REGEX: "REGular EXpression"...a pattern matching expression | ||
+ | DATE: a date...format my vary | ||
+ | TIME: a time...format my vary | ||
+ | NUMBER: a numeric value | ||
+ | |||
* find . -type f -exec grep -n "foo" {} /dev/null \; # search regular files for "foo" inside...printing "path/filename:line:content" | * find . -type f -exec grep -n "foo" {} /dev/null \; # search regular files for "foo" inside...printing "path/filename:line:content" | ||
* find . -type f -exec ls -hlatr {} \; | sort -hk5,5 # long list all files under a directory, sort smallest to largest (human size) | * find . -type f -exec ls -hlatr {} \; | sort -hk5,5 # long list all files under a directory, sort smallest to largest (human size) | ||
Line 15: | Line 27: | ||
* >foo || cp /dev/null foo # zeros out file "foo" | * >foo || cp /dev/null foo # zeros out file "foo" | ||
* \foo || "foo" # unalias command "foo" | * \foo || "foo" # unalias command "foo" | ||
+ | * while [ 1 ]; do foo; sleep foo; done |
Revision as of 10:35, 14 November 2016
Favorite Commands:
Some variables: FILE: a filename PATH: a directory/file path LINE: a line's contents COMMANDS: a/many commands like awk, cat, echo, grep, etc. LITERAL: a literal/static variable no REGEX REGEX: "REGular EXpression"...a pattern matching expression DATE: a date...format my vary TIME: a time...format my vary NUMBER: a numeric value
- find . -type f -exec grep -n "foo" {} /dev/null \; # search regular files for "foo" inside...printing "path/filename:line:content"
- find . -type f -exec ls -hlatr {} \; | sort -hk5,5 # long list all files under a directory, sort smallest to largest (human size)
- rm -rf foo # remove a directory "foo" and all content
- awk -F'foo' '{print $number}' # print the column (number) delimited by "foo"
- locate foo # print the path/filename of file name matching "foo"
- less -S foo # pager with no line wrap
- du -hd1 | sort -h # disk usage (human size),one level deep and sum by directory...pipe to sort smallest to largest
- wget foo # get a file from http/ftp
- scp foo username@hostname:/tmp # put "foo" to location
- scp username@hostname:/tmp/foo . # get "foo" from location
- cat foo # display contents of file "foo"
- vi foo # edit/view file "foo"
- echo $foo # display contents of variable "foo"
- >foo || cp /dev/null foo # zeros out file "foo"
- \foo || "foo" # unalias command "foo"
- while [ 1 ]; do foo; sleep foo; done