1

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
asked Oct 1, 2018 at 12:11

1 Answer 1

2

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
3
  • could you also clarify what does $ do in this command? Commented 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. Commented Oct 1, 2018 at 13:36
  • Or with redirection : for f in *; do > "${f}.done"; done Commented Oct 1, 2018 at 14:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.