popd: cd but remember where you were
pushd: return to origin directory
<command> | wc -l
ls -lrt | awk '{ total += $5 }; END { print total }'
-v : verbose
-r : copies data recursively (but don’t preserve timestamps and permission while transferring data
-a : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
-z : compress file data
-h : human-readable, output numbers in a human-readable format
rsync -avz localdir/ user@remotehost:/remotedir
rsync -avzh user@remotehost:/remotedir /localdir
See more examples at: Techmint Rsync examples
Basic construction:
find <dir> <something>
Useful options
-mtime (modification time); e.g -1 is one day ago
can be between with -mtime -1 -mtime +2
-name '*.txt'
-type -[d,f] ; f=file, d=directory
-L follows symbolic links
-exec ls -l {} \;
-empty; find files of zero length or empty directories
Combining commands
-name '*txt' -exec grep “something” {} \;
equivalent to
find -name ‘*txt’ | xargs grep “something”
The CEDA command line arrivals deleter
arrivals_deleter
Linux command cut is used for text processing. You can use this command to extract portion of text from a file by selecting columns.
$ cut -c2 test.txt
$ cut -c1-3 test.txt
$ cut -c3- test.txt
$ cut -c-8 test.txt
$ cut -c- test.txt
$ cut -d':' -f1 /etc/passwd
$ grep "/bin/bash" /etc/passwd | cut -d':' -f1,6
$ grep "/bin/bash" /etc/passwd | cut -d':' -f1-4,6,7
$ grep "/bin/bash" /etc/passwd | cut -d'|' -f1
$ grep "/bin/bash" /etc/passwd | cut -d'|' -s -f1
$ grep "/bin/bash" /etc/passwd | cut -d':' --complement -s -f7
grep "/bin/bash" /etc/passwd | cut -d':' -s -f1,6,7 --output-delimiter='#'
$ grep bala /etc/passwd | cut -d':' -f1,6,7 --output-delimiter=$'\n'
ps axu | grep python | sed 's/\s\+/ /g' | cut -d' ' -f2,11-
(Thanks to Alan Iwi for this information)
nohup ./{script} > {filename}.out 2>&1&
scp {data} {username@loc:/destination}
Stop process: CTRL+z
Set to run in background: bg {Process_ID}
Release process from session: disown -h {Process_ID}
Remove from end of string
a=test01.nc
b=${a%nc}
echo b
=> test01.
To remove from start of string use #
for (( y=1; y<=10; y++)); do
....
done
Loops using alphabet and typeset to set length of a counter string
$ typeset -Z2 counter
$ counter=00
$ for ens in {a..z}; do
$ ((counter=counter+1))
$ echo $counter
$ echo $ens
$ done
cat {argsfile.txt} | xargs {script.sh}
Create a symbolic link with the command
$ ln -s <source> <linkname>
source is the directory to link to
linkname is the symbolic link name to the source
dvips {filename}.dvi
ps2pdf {filename}.ps {filename}.pdf
lp -d{PRINTER} -o {filename} (-o fit to page)
Python: setup epd
CDO: setup cdo
cp
cp -p: preserves permissions.
scp
rsync -a(v)zhe ssh <data> <destination>
usbcheck
usbeject
latex <filename>
bibtex <filename>
xdvi <filename>
dvips <file>.dvi
ps2pdf <file>.ps <file>.pdf
a2ps <file> | lp -d<printer>
xpp
rlpstat
rcancel
ncdump -c <file> | more
ncdump -h <file>
CREATE: tar cf <file>.tar <files>
RESTORE: tar xf <file>.tar
CREATE: tar -xcvf <file>.tgz <files>
RESTORE: tar -zxvf <file>.tgz
grep
whence
ps -u <userid>
ps kill [-9]
bg: &, CTRL+z "bg"
fg: "fg"
ls -l
ls -ltr
ls -lq
ls -lh
ls -F (directories)
ls -F <dir> look in dir
ls -sh (size in h converts to human readable)
du -sh */
df -h