LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-30-2014, 04:07 AM   #1
ilesterg
Member
 
Registered: Jul 2012
Distribution: CentOS, SLES, RHEL, HP-UX, OpenSUSE Tumbleweed KDE
Posts: 504

Rep: Reputation: 54
create file in a single command


Hi all,

Howdie?

Is it possible for me to do the following in a single command?

1. List all files ending in TXT (ls *.TXT)
2. For each file returned above, create a pair by appending .!!! (something like *.TXT.!!!) using touch

For example, I have 2 files:
name1.TXT
name2.TXT

the command will create 2 additional files:
name1.TXT.!!!
name2.TXT.!!!

Thank you!
 
Old 01-30-2014, 04:45 AM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
I a for loop you can do
Code:
for i in *.txt; do touch $i.\!\!\!; done
the backslashes are important in order to prevent Bash from interpreting the '!'.

Markus
 
1 members found this post helpful.
Old 01-30-2014, 05:09 AM   #3
ilesterg
Member
 
Registered: Jul 2012
Distribution: CentOS, SLES, RHEL, HP-UX, OpenSUSE Tumbleweed KDE
Posts: 504

Original Poster
Rep: Reputation: 54
Awesome! Thank you very much!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] create many directory with single command Tauatioti Linux - Newbie 3 11-29-2013 06:36 PM
Create Debian File for Single Python3 Script DevynCJohnson Linux - General 7 06-18-2013 06:38 AM
[SOLVED] add 250 single column files to create one file wilelucho Programming 10 06-27-2012 03:05 PM
[SOLVED] How to create a single file with size of 50 GB sanjay87 Linux - Server 2 04-18-2012 03:29 PM
MySQL - command - create user/single database dmedici Linux - Software 3 06-21-2004 04:17 PM


All times are GMT -5. The time now is 10:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration