LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 03:07 AM   #1
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

Rep: Reputation: 72
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, 03:45 AM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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, 04:09 AM   #3
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

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


Reply



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 05:36 PM
Create Debian File for Single Python3 Script DevynCJohnson Linux - General 7 06-18-2013 05:38 AM
[SOLVED] add 250 single column files to create one file wilelucho Programming 10 06-27-2012 02:05 PM
[SOLVED] How to create a single file with size of 50 GB sanjay87 Linux - Server 2 04-18-2012 02:29 PM
MySQL - command - create user/single database dmedici Linux - Software 3 06-21-2004 03:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:58 AM.

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
Open Source Consulting | Domain Registration