Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-30-2003, 05:47 PM   #1
Registered: Apr 2003
Posts: 87

Rep: Reputation: 15
bash scripting - editing files

How would you, for example, replace the number in the Nth column (columns are consecutive characters separated by blank space) of the line that contains "bleh" in the file called FILENAME with 12345?


Last edited by brian0918; 06-30-2003 at 05:50 PM.
Old 06-30-2003, 06:16 PM   #2
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 110Reputation: 110


mv -f ${FILENAME} ${FILENAME}.old
awk '/bleh/{$4=12345 ; print}' ${FILENAME}.old >${FILENAME}


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
moving files that have spaces in variables -bash scripting bhar0761 Programming 10 09-22-2005 07:30 AM
BASH Scripting akilles Linux - Newbie 5 11-10-2004 07:26 PM
BASH If-then-else Scripting Help xianzai Programming 4 10-29-2004 04:09 AM
Bash scripting Gunslinger_ROL Programming 5 09-28-2004 11:37 AM
bash scripting - editing files brian0918 Linux - Newbie 2 07-01-2003 02:27 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:57 AM.

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