renaming files

silver.bullet at zoho.com silver.bullet at zoho.com
Sun Sep 27 19:46:54 UTC 2015


On Sun, 27 Sep 2015 21:42:28 +0200, I wrote:
>rename.bash  test 5  test 6  test 7  test 10  test 20
>rename.bash  test 2  test 3  test 4  test 5  test 6

Oops, it should be o=0 ;).

[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=0
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 1  test 2  test 3  test 4  test 5
[rocketmouse at archlinux Desktop]$





More information about the ubuntu-users mailing list