LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-01-2012, 08:02 AM   #1
bino25
Member
 
Registered: Dec 2010
Posts: 50

Rep: Reputation: 11
scripting question


As a noob to scripting, I was wondering if I could get some help.

Here is what I am trying to do. I have 2 files,
file1_ack_132134234.dat
file2_ack_451345134.dat

Any file containing the word "normal" (in this case file1 does and file2 does not) needs to be renamed.

So in my example, file1_ack_132134234.dat would need to be renamed to file1_norm_132134234.dat

Any suggestions/ideas?

TIA
 
Old 03-01-2012, 08:56 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,657
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
One strategy would be to use the grep command to find the names of all the files that do contain the word.   If you wanted to, you could then "pipe" that output to the xargs command so that it would execute a rename. You should start with man grep and man xargs and man bash and carefully and thoroughly read all three of them before proceeding.

(No, no, no... don't just breeze through, don't skim and say you didn't ... ... you are playing with very useful high-explosives here. Stuff that can do what you want, or what you don't want , in about one millisecond.)

Last edited by sundialsvcs; 03-01-2012 at 08:57 AM.
 
  


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
scripting question. mrbutabara Linux - Newbie 8 01-27-2009 09:43 AM
Scripting question nazs Programming 4 04-27-2008 12:48 AM
Scripting question msandford Linux - Newbie 4 09-05-2005 10:23 AM
scripting question gearoid Programming 3 05-26-2004 02:43 PM
scripting question cyph3r7 Linux - General 1 04-05-2004 02:12 PM

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

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