Saori Yoshimoto work notes since 2018

Showing posts with label Scripts/shell. Show all posts
Showing posts with label Scripts/shell. Show all posts

Friday, August 20, 2021

[Linux-centOS] Useful command "ZIP", "UNZIP"

-ZIP compress :                     zip -r <compress file name>.zip <target name>

-ZIP compress + password:    zip -er <compress file name>.zip <target name>

------

◆unzip

unzip '*.zip'

◆If you have a large number of zip files to unzip, use "xargs"

find . -name '*.zip' | xargs -n1 unzip

◆"unzip" + "xargs" + Specify the output destination.

find . -name '*.zip' | xargs -n1 unzip -d <output directory name>

※The files hit by "find" command are passed to "xargs" command for unzipping. 

"xargs" will "unzip" every time it finds a file by specifying "-n1".

Friday, January 11, 2019

[script-shell] filename replace

It works for based on Bash(Linux).
ex). execution method
1(file name): rename_replace.sh
2(exetcute ): ./rename_replace.sh  
-----------------------------------------------
find . -type f -name '*.hipnc' | while read FILE ; do
    newfile="$(echo ${FILE} |sed -e 's/siy/sri/g')" ;
    mv "${FILE}" "${newfile}" ;
done


-about sort command
https://eng-entrance.com/linux-command-sort

-about sed command
https://eng-entrance.com/linux-shellscript-replacement

Thursday, November 29, 2018

[script-shell] Renaming files to sequential numbers

It works for based on Bash(Linux).
ex). execution method
1(file name): test_rename.sh
2(exetcute ): ./test_rename.sh  
-------------- 
i=1

for f in $(ls -1 *.jpg | sort -t '.' -k2h)
do
 mv "$f" $(printf "001_guide.%04d.jpg" $i)
 : $((i++))
done