Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-30-2014, 03:07 AM   #1
Registered: Jul 2012
Distribution: Arch, Debian, and CentOS/RHEL
Posts: 541

Rep: Reputation: 56
create file in a single command

Hi all,


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:

the command will create 2 additional files:

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

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

1 members found this post helpful.
Old 01-30-2014, 04:09 AM   #3
Registered: Jul 2012
Distribution: Arch, Debian, and CentOS/RHEL
Posts: 541

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


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 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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:56 PM.

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