A few Linux commands
Item | Command |
---|---|
Copy lines containing ' 0' (four blank spaces followed by a zero) | $awk /'^ 0'/'{print $0}' file1.txt > file2.txt |
Disk space usage | $df -h |
Copy lines from 1001 to the rest of the file to another file | $tail --lines=+1001 file1.txt > file2.txt |
Appending contents into another file | :w>>filename.txt |
Copy all the lines containing the pattern NNN from fil1.txt and paste them into file2.txt | $awk /^NNN/'{print $0}' file1.txt > file2.txt |
Copy first 1000 lines to another file | $head -1000 file1.txt > file2.txt |
PDOS | $~/bin/pdosxml C.PDOS > C.DOS_xml |
Listing properties of files with respect to time accessed | $ls -t -als |
Replacing XYZ with ABC in file *.* | $sed -i s/'XYZ'/'ABC'/g *.* |
IP address | $ifconfig |
Finding a folder named xyz | $find directorypath2besearched -name xyz |
Chaning ownership of a folder foldername | $chown -R foldername ownername |
Size of folder XYZ | $du -s XYZ |
Copy last 1000 lines to another file | $tail -1000 file1.txt > file2.txt |
for bash | $source ~/.bashrc |
for csh or tcsh | $source ~/.cshrc |
To check all the available PATHs | $echo $PATH |
To check which libraries are loaded by an executable | $ldd NameOfExe |
To see a list of the environment variables that are already set on your machine | $env |
To see the appearances of the name Einstein in an opened document (appearances are highlighted) | /Einstein |
Check the full path of the environment variable PETSC_DIR | $echo $PETSC_DIR |
Which shell | echo $SHELL |
Quota on teragrid | quota -v |
ifort version | ifort --version |
Link lapack (TACC) | -Wl,-rpath,${TACC_MKL_LIB} -L ${TACC_MKL_LIB} -lmkl_lapack |
Link Scalapack (TACC) | -Wl,rpath,${TACC_MKL_LIB} -L ${TACC_MKL_LIB} -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread |
Details of a module | module show mkl/12.1 |
To find default versions look for asterisk (LLNL) at the command prompt | dpkg-defaults |
to find default compilers in use in your shell (LLNL) | use -l compilers |
Check the version of a compiler | mpif90 -V |
Architecture | uname -a |
Math in bash script | sed -i s/'Z1'/$((100*Z-99))/g rand_num.txt |
change | sed -i s/'p50_1'/'fynman_'$Z/g dft.qsub |
Starting interactive mode | qsub -I |
Loading a modeul | module load openmpi/gnu (check first with module avail)) |
Delete line containting a matching text 'hello' | sed -i '/\<keyword\>/d' *.txt |
To use sed in iMac | sed -i '' s/'nan'/'0'/g vfield_*.txt |
Removing a line containing, say, '#t=5' in a file named filename.txt using VIM command | $sed -i /'#t =5'/d filename.txt |
To check underlying compilers of an executable, e.g. mpiifort | $mpiifort -show |
Currently Loaded Modulefiles | $module list |
Deleting the first line from a text file | sed -i '1d' filename |
go to start/end of a command line (Mac) | ctrl+a/ctrl+e |
To delete all lines containing the word 'nothing' | $sed -i '/nothing/d' filename, $sed '/nothing/d' input.txt > out.out |
Changing permission to all files in a folder | $chmod -R 755 {DIR} |
Delete 2nd to 4th line in a file C.XV | $sed -i '2,+2d' C.XV |
Delete everything but 2nd to 4th line in a file C.XV | $sed -i '2,4!d' C.XV |
FARBER: checking group statistics | $qstatgrp |
iMAC: Search a text "Good" in files at the current location | $mdfind "Good" -onlyin . |
LINUX: search a text 'pattern' | $grep -rnw '/path/to/somewhere/' -e "pattern" |
replace folder path using sed | $sed -i s/'\/home\/1621\/softwares\/espresso-5.2.0\/pseudo\/upf_files\/'/'test'/g input.txt |
Creating bash file (if not there already) | $touch ~/.bash_profile |
shortcut to connecting a remote host | $alias shortname='ssh username@hostname' |
Showing 52 items