Shell - for loop


2022-04-12 11:14PM
[/home/zzh/aaa]$>lh
total 8.0K
-rw-rw-r-- 1 zzh users    0 Apr 12 05:08 c.txt
-rw-rw-r-- 1 zzh users    0 Apr 12 05:08 b.txt
-rw-rw-r-- 1 zzh users    0 Apr 12 05:08 a.txt

2022-04-12 11:14PM
[/home/zzh/aaa]$>for x in *.txt; do
>> mv $x $x.bak
>> done

2022-04-12 11:16PM
[/home/zzh/aaa]$>lh
total 8.0K
-rw-rw-r-- 1 zzh users    0 Apr 12 05:08 c.txt.bak
-rw-rw-r-- 1 zzh users    0 Apr 12 05:08 b.txt.bak
-rw-rw-r-- 1 zzh users    0 Apr 12 05:08 a.txt.bak