help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] copy files w


From: Chris F.A. Johnson
Subject: Re: [Help-bash] copy files w
Date: Sat, 29 Apr 2017 21:07:56 -0400 (EDT)
User-agent: Alpine 2.10 (DEB 1266 2009-07-14)

On Sun, 30 Apr 2017, Val Krem wrote:

Hi all,

I have several files with the same  extension name(*.txt). I want to have   
copy of these files by attaching a suffix to each of the files. Example 
test1.txt should be copied to test1_new.txt. The suffix to be added in all 
files is the same. I tried using this but did not work.

ls *.txt | xargs -I {} cp {} {}_new.txt

test.txt should be test_new.txt
but I got test.txt_new.txt

what should I do to make work?

for file in *.txt
do
  cp "$file" "${file/.txt/_new.txt}"
done

--
Chris F.A. Johnson, <http://cfajohnson.com>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]