LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-28-2005, 01:32 PM   #1
Spacepup
LQ Newbie
 
Registered: Jul 2005
Posts: 1

Rep: Reputation: 0
renaming text files based upon a pattern in their content


How would I go about accomplishing the following?

1. Read a file looking for a particular pattern. i.e footest:
2. Skip the next several blank spaces (the # of which is variable) until the runjob name. i.e. foojobname
3. Rename the file based upon the runjob name and date/time of file
4. Repeat for all files in the directory

I know I can use grep to search through the files but don't know what tool(s) I can use to skip blanks and capture just the 8 char job name from the middle of the line. Would I have to store the jobname into a variable or can I pipe the output of grep directly into say mv to do the renaming?

Thanks for any assistance
 
Old 07-28-2005, 01:43 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Code:
mv FILE `sed -n 's/footest: *(.*)$/\1/p' < FILE`
I think that's correct.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove files based on content stefaandk Linux - General 2 08-13-2005 08:03 AM
Replace text of unknown content with other text in file brian0918 Linux - Software 1 07-14-2005 03:22 PM
Searching text files by content will103 Linux - Software 1 01-24-2005 07:43 AM
Find string pattern in directory of text files magnum818 Linux - Newbie 2 10-15-2003 08:19 PM
Finding files based on content benjaminrtz Linux - General 2 08-04-2002 11:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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