I have AIX 7.1
. Let's say I have a directory with files like these:
1.txt
lala.csv
I need to create empty copies of these files with a new extension in the same directory, like so:
1.txt.done
lala.csv.done
I can't seem to find the right option for doing this.
Rui F Ribeiro
57.9k28 gold badges154 silver badges237 bronze badges
1 Answer 1
Simply loop over every file (here, skipping dotfiles by default), and touch the corresponding file:
for f in *; do touch "${f}.done"; done
answered Oct 1, 2018 at 12:21
-
could you also clarify what does $ do in this command?xaren jo– xaren jo2018年10月01日 13:32:03 +00:00Commented Oct 1, 2018 at 13:32
-
Sure, @xarenjo ; it introduces a variable expansion. I used curly braces out of habit, to explicitly delineate what the variable is (f). The end result is that the touch command sees the value of
$f
— each existing filename — during each loop.2018年10月01日 13:36:40 +00:00Commented Oct 1, 2018 at 13:36 -
Or with redirection : for f in *; do > "${f}.done"; donectac_– ctac_2018年10月01日 14:39:11 +00:00Commented Oct 1, 2018 at 14:39