LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 05-26-2006, 11:20 AM   #1
gamor
Member
 
Registered: Jul 2004
Posts: 77

Rep: Reputation: 15
changingthe name of a set of files


I am trying to run the command cat on a set of files with the extension .sgm. I want the output to be in the same filename with the extention .sgml for example
That is the command:
cat *.sgm "some processing" > processedfile.sgml
How can I keep the same file name in output files. Please help.
Rita
 
Old 05-26-2006, 11:45 AM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 271Reputation: 271Reputation: 271
http://www.linuxquestions.org/questi...hreadid=388053
 
Old 05-27-2006, 08:37 AM   #3
gamor
Member
 
Registered: Jul 2004
Posts: 77

Original Poster
Rep: Reputation: 15
The link you sent me shows the command used to change teh extention of a set of files. I am already using the command cat, I want the processed files using cat to be written in the same file name with a different extention so I can keep the original file and the processed file.
 
Old 05-27-2006, 09:22 AM   #4
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Code:
for i in $(ls -1 *.sgm); do cat $i | ... > $(basename $i .sgm).sgml; done
Replace "..." with the command that does your processing with STDIN and prints the result to STDOUT. This will only work if your filenames don't contain whitespace.
 
Old 05-27-2006, 10:29 AM   #5
gamor
Member
 
Registered: Jul 2004
Posts: 77

Original Poster
Rep: Reputation: 15
Thanks a lot, it works.
Ghita
 
  


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
How do you like to set up your files with a header.h file? RHLinuxGUY Programming 5 03-30-2006 07:38 AM
how to set descriptions for files served by Apache servnov Linux - Newbie 2 11-12-2004 07:35 AM
How to set the IP and which configuration files? jonathanztaub Linux - Networking 2 05-04-2004 05:28 AM
[makefile] Do header files need to be set targets? chuanyung Programming 2 03-11-2004 09:22 PM
How to find text in a set of files? concoran Linux - General 2 06-01-2003 07:36 PM


All times are GMT -5. The time now is 01:43 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