FILES:
cat file_name--> show files
-b -->back some lines
-g (to line number)
-G (end of file)
q -->exit,End
> prog1 --> prog1: pwd
ls -l
who
cat file1 file2 > file8 --> put file1 file2 into file8
>> --> append
* |grep my_word|more --> search for my_word at
the files at the directory
pgrep --> procces number
my_prog& --> run at the backround
awk -f prog1 text1 -->put a program on a file
alias --> list of aliases
alias xx=pwd;ls -l;echo the end;clear:
alias rm=/bin/rm -i
unalias alias_name --> cancel alias
uniq file1 -->shows file with no doble lines
-d f1 -->shows the lines that clone themselves
-u f1 -->shows the different lines
diff file1 file2 -->compare two files
touch f1 --> make empty file name f1 (like empty VI)
WC file_name -->shows:number of lines,words, sighns
-l -->lines
file file_name -->shows what kind
find /user/oded -name passwd --> search for passwrd
from /user/oded down
. -->search from here
. -mtime -3 -ls -->find files created/modified in
the last 30 days
-user moshe -name f1 -ok rm {} \; -->find moshes f1
files ask before del
-type l,f,d --> symbolic link
-type l -exec ls -l {} \; > out.txt 2> /dev/null
-name file_name -exec ls -l {} \; -->do something on what u found
-ok ls -l {} \; -->ask each time
-size -100k --> less than 100 blocks
(block=512 bytes)
-empty --> for empty files
-cmin -1 --> for changed files 1 min ago
-ctime --> in days
-amin +5 --> entered more than 5 min
-UID 501 --> code of owner (root=0)
-user oded --> by user owner is oded
-gid 201 --> by group number
group student --> by group
-links +5 --> by link number
-perm 400 --> by this permition
locate keep_adsl -->
tells where the file is.if there is error u delete
the /var/lib/slocate/slocate.db than: updatedb
whereis keep_adsl -->
tells u where the file is
more file1 ; more file1 /hi --> searce for "hi"
less file1
man file1 /hi -->searce for "hi"
head file1-->shows first rows
-2 --> 2 rows
-c 1k file1 :k-kilobyte,b-byte,m-megabyte
-c 3 -->3 digits
tail -f -->shows 10 last rows :tail -15 file|head -1
-->line 15 from end
spell < text1 --> check spelling
grep Login user=mosh /var/log/maillog
--> search for string at maillog
-n text file1 file2 -->search a frase with no. of row
-n [a-d]an data1
-c --> haw many times accure
-v --> where root dont accure
-i --> ignore upper case letters
"^user" -->search for "user" at beggining of line
"text$" -->search for "text" at end of line
^[^no] -->everything without "no" at the begining
ls /usr/oded|grep passwd --> search passwrd in oded dir only.
sort file1 --> sort file
file1 file2 -->2 files together
-r --> from end to begining
-t= +1 -2 file1 -->sort 2nd word "=" is
between or +1 -2 file1>file2
-t= +1 -2 +5 -6 file1 -->secondary sort
sed:
^ match beginning of line
$ match end of line
. match any single charecter
n replace n instance of pattern
g replace all instances
sed s/string_to_replace/new_string/g file1
-->changes the string in file1
@ @ @ <--
also with @
sed -e s/black/white/2 file --> change every 2nd
word at every line
/not/s/black/white/g file ->change black with
white only where not
1,2d file -> remove lines :1+2
3d file -> delete line 3
1,2s/LINE/line/ file ->only at lines
1+2 change LINE to line
/line/d file -> delete all lines where there is line
/hello/,/bye/d file ->delete all lines
from hello to byeor to end
s/ */ /g file ->change 1 or more space into single space
s/ *$// file -> remove all spaces from end of line
s/^/ / file -> insert a space at the beginning of a line
s/^[0-9]* // file -> removes all numbers at
beginning of the line
s/b[aeio]g/bug/g file ->change al occurences of
bag,beg,big,bog to bug
s/t\([aou])\)g/h\1t/g ->change tag,tog,tug to
hat,hot,hut respectively
s/^[ ]*// remove leading blanks
/^$/d file remove blank lines
/^\#/d deletes every line begins with #
/^\/\*/d file ->delete lines
begin with "/*".spacial:*,/ are escaped
s/$/./ will stick a period at
end of line even blank lines
info:if u have . u must add it like: s/12.*A//g
--> replace from 12 to A..
mkdir lower
for FILE in /var/log/test.*
do
sed s/ */ /g $FILE > lower/$FILE
done
-----
rev file | sed -e s/\(.\{7\}\).*/\1/g | rev :
gives the Last 7 chars in file
|