라벨이 shell인 게시물 표시

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

File searching and Remove the searched files in Powershell

This is very useful when you are managing your files in your computer (Windows) 1. Identify files in certain folder >>> Get-ChildItem C:/testfolder/* 2. Identify files in certain folder and remove all of them >>> Get-ChildItem C:/testfolder/* | ForEach ($_) {Remove-Item $_.fullname} 3. Search certain files including '.test' >>> Get-ChildItem C:/* -Include *.test 4. Search certain files including '.test', but excluding the files which begin with 'abc' >>> Get-ChildItem C:/* -Include *.test -Exclude abc*.test 5. Search the files including Sub folders >>> Get-ChildItem C:/* -Include *.test -Recurse 6. Search the files including Sub folders and remove all of them >>> Get-ChildItem C:/* -Include *.test -Recurse | ForEach ($_) {Remove-Item $_.fullname} 7. Search the files, Print them, and then remove all of them >>> Get-ChildItem C:/* -Include *.test -Recurse || ForEach (

The meaning of '$_' in Powershell

이미지
When you are using Powershell, you easily run into this: $_ The meaning is the variable for the current values in the pipe line. For example, >>> 1,2,3 | %{ write-host $}% 1 2 3 Additionally, %{ } block means every value in the array. Thanks Have Fun!

ForEach in Powershell

ForEach - Loop statement Syntax is as below. ForEach (item In collection) {ScriptBlock} item: A variable to hold the current item collection: A collection of objects e.g. filenames, registry keys, servernames ScriptBlock: A block of script to run against each object. Thanks, Have Fun! The source: http://ss64.com/ps/foreach.html

How to open folder in Powershell

There are many ways to open folder in Powershell. 1) Invoke-Item cmdlet: ii >>> ii . >>> ii C:\windows 2) start >>> start . >>> start C:\windows 3) explorer.exe >>> explorer.exe . >>> explorer.exe C:\windows 4) explorer >>> explorer . >>> explorer C:\windows 5) hh >>> hh . >>> hh C:\windows >>> hh http://xxx.xxx.xxx/xxx

'For' statement in Powershell

Fundamental syntax for (initial; condition; repeat)      { command block } Example: >>> for ($i=1, $i -le 10; $i++){      Command block      }      

Python IDLE execution in shell, text-based tool such as linux terminal or windows powershell.

When you are using text-based system such as linux terminal or windows dos (or powerhsell), you may want open file of  python ( blahblah.py ) through IDLE. In this case, you can use below commands If python path is here C:\Python27\ In order to open IDLE, you have to open using pythonw.exe So you can do like this. C:\Python27\pythonw.exe C:\Python27\Lib\idlelib\idle.py .\blahblah.py Thanks! Have fun!

Submit File for Iterative Calculation in Density Functional Theory (VASP) using Bash Shell

이미지
Many times we run into the situation which we should calculate iterative. In this case, this bash shell script can be used very helpfully. Here is example script. This script is that we can calculate iteratively changing the value of ISIF in INCAR file. sed "s/ISIF=${prei}/ISIF=${i}/" INCAR > temp means that find the lines with ISIF=value of prei (initial value is defined 1) and change it to ISIF=value of i ( i is changed from 1 to 7 ). So, this bash shell makes it possible to simulate with various kinds of relax conditions. $mpi_cmd -np $num_proc -hostfile $PBS_NODEFILE $lmp_cmd > vasp.log 2>&1 This command is excution command. (This is different according to your cluster environment) if [ "${prei}" -eq 7 ]; then mkdir calculatenum_${i} cp * calculatenum_${i} else prei=${i} cp CONTCAR POSCAR fi Here are the if loop that determines wheter calculated files save or not. Last calculation will be saved. The others is not sa