Home manipulating-strings
Post
Cancel

manipulating-strings

String Length

${#string}

Substring Extraction

${string:start position[:optional length]}

eg

for file in *.aac; do  mv ${file:0:${#file}-4}.aac ${file:0:${#file}-4}.mp3 done

on command line, use tr

1
2
3
4
5
6
7
8
9
10
11
find . -iname \*ilo\* -exec basename {} \;
lon-hcesx24-ilo.cfg
lon-hcesx29-ilo.cfg
lon-hcesx12-ilo.cfg
lon-hcesx19-ilo.cfg

find . -iname \*ilo\* -exec basename {} \; | tr -d '.cfg'
lon-hesx24-ilo
lon-hesx29-ilo
lon-hesx12-ilo
lon-hesx19-ilo
This post is licensed under CC BY 4.0 by the author.