라벨이 Linux인 게시물 표시

Check or List Available Modules or Programs in Linux

Simply type below! >> module avail Thanks, JF

Counting lines in file and stdout in Linux

Try use this! wc -l e.g. wc -l filename e.b. grep word filename | wc -l Thanks, JF

Install Python to User Account in Linux

1. Download PythonO.O.tgz 2. Unzip >> tar -xvzf PythonO.O.tgz 3. cd PythonO.O 4. ./confiure --prefix=$HOME/python27/           (example) 5. make 6. make install 7. Setup environment variables Thanks, JF

Find file in Linux!

find $HOME -name 'name' -print Thanks, JF

line copy and paste in vi of Linux system

Copy -> yy Paste -> p Thanks. JF

delete specific line from a file in linux

1. n: the number of line sed 'nd' filename (just print) sed -i 'nd' filename (change file) 2. word: the word contained in line which I want to delete sed '/word/d' filename (just print) sed -i '/word/d/ filename (change file) Thanks, JF

VNC commands in Linux

i.e. vncserver :13 vncserver -geometry 1600x900 :13 vncserver -kill :13 vncserver -list vncpasswd Thanks, JF

Linux example of sort

sort file : sorting file using first column sort -k 2 file : sorting file using second column sort -r -k 2 file : sorting file using second column in reversal order sort file > file.txt : sorting file and save to file.txt Thanks, JF

Usage of seq, echo, tail, awk, sort, cat for data analysys

for i in `seq 0 1 8` do    cd ${i}/magmom    for j in `seq 0 1 70`    do       echo ${j} `tail -1 OSZICAR_${j}` >> res    done    awk '{print $1, $4}' res >> res.out    sort -k 2 res.out | tail -1 >> min_${i}    cat min_${i} >> ../../mins; cd ../.. done Thanks, JF

Linux example of sed

* sed: Stream EDitor 1. search and print sed -n 'asdf/p' file : Read file line by line without print (-n), and print a line if asdf is found. 2. substitution sed 's/asdf/qwer/' file : replace asdf by qwer, and does not change original file. just print sed 's/asdf/qwer/' file > copyfile : replace asdf by qwer, and copy file to copyfile sed -i 's/asdf/qwer/' file : replace asdf by qwer and change original file If you would like to do for entire file, using '/g'. sed -i 's/asdf/qwer/g' file : replace asdf by qwer for entire file, and change original file Thanks, JF

Delete a line including a word in a file using sed in Linux

If you want to delete a line including 'Fast' in a file 'abc.txt', do this >> sed /Fast/d abc.txt Below is example. >> cat abc.txt abc abc abc abc Fast abc >> sed /Fast/d abc.txt abc abc abc abc abc Thanks, JF

Replacing words within files in linux (find, sed)

이미지
Hi. When you want to replace words in files, do like this! 1. Find files having words you want to replace 2. Change it ! Here is example! I want to replace all "Fe" to "Mo" at all POSCAR files. Thanks, Jin-Myoung Lim

Finding files with name "XXX" in linux

이미지
Hi, When you want to find files with name "XXX", you can use this at this folder. >> find ./ -name "XXX" Here is example. I wanted to find files with name including "POSCAR*" >> find ./ -name "POSCAR*" Thanks, Jin-Myoung Lim

Basic commands for Linux/Mac OSX and Windows Powershell

Basic commands for operating systems ( Linux/Mac OSX and Windows ) I would like to introduce basic commands and their brief explanations. If you want detail usage, googling them! 1. Linux/Mac OSX pwd:  print working directory hostname:  my computer's network name mkdir :  make directory cd:  change directory ls:  list directory rmdir:  remove directory pushd:  push directory popd:  pop directory cp:  copy a file or directory mv:  move a file or directory less:  page through a file cat:  print the whole file xargs:  execute arguments find:  find files grep:  find things inside files man:  read a manual page apropos:  find what man page is appropriate env:  look at your environment echo:  print some arguments export:  export/set a new environment variable exit:  exit the shell sudo:  become super user root chmod:  change permission modifiers chown:  change ownership 2. Window

File searching and Remove the searched files in Unix/Linux shell

When it comes to Linux/Unix operating system, you can use shell. 1. Identify detail information of files >>> ls -l 2. Identify detail information of files including sub folders >>> ls -lR or >>> ls -lRs 3. Search files which begin with test >>> ls -lRs | grep -i test* by using '-i' option, you can display the information of location (folders) or >>> find . -name 'test*' -print this would be searching from this present folder 4. Search files which begin with test and then remove all or them >>> find . -name 'test*' -exec rm {} \; -exec command ;       : Execute command. {}                         : The string {} is replaced by the current file name \                         : For escaping 5. Some other usage >>> find . -type d -exec chmod 755 {} '; From this present folder, change all of folder's permission to 755 >>> find . -type f -exe