renaming files
silver.bullet at zoho.com
silver.bullet at zoho.com
Sun Sep 27 19:42:28 UTC 2015
On Sun, 27 Sep 2015 14:31:01 -0400, Bill wrote:
>example:
>
>before: test 5, test 6, test 7, test 10, test 20
>
>these files should be renamed as
>
>after: test 1, test 2, test 3, test 4, test 5
[rocketmouse at archlinux Desktop]$ ls
rename.bash
[rocketmouse at archlinux Desktop]$ cat rename.bash
#!/bin/bash
touch test\ 5 test\ 6 test\ 7 test\ 10 test\ 20
ls -v
sleep 3
o=1
for i in $(ls -v | sed s/"test"/""/g); do
mv -i "test $i" "test $o"
((o=o+1))
done
ls -v
exit
[rocketmouse at archlinux Desktop]$ bash rename.bash
rename.bash test 5 test 6 test 7 test 10 test 20
mv: cannot stat ‘test rename.bash’: No such file or directory
rename.bash test 2 test 3 test 4 test 5 test 6
[rocketmouse at archlinux Desktop]$
More information about the ubuntu-users
mailing list