LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 01-26-2004, 01:42 AM   #1
Bassam
Member
 
Registered: Mar 2003
Location: Malaysia
Posts: 63

Rep: Reputation: 15
How to find and change a specific text in a text file by using shell script


Hi All,
I am using shell script programming and I have text file consistes of 2 fields separated with TAB space, I want to search for a specific value in the second feild then change that value and then read the value of the first field of the same record.

the text file is

0 198.12.45.30
1 250.12.180.129
2 110.115.20.128
3 200.200.2.200

for example I want to find the value 110.115.20.128, change it to 0.0.0.0 and read the value of the first field for the same record which is 2.

so could u tell me how can I do this operation by using shell script programming?

Regards
Bassam
 
Old 07-18-2005, 07:15 PM   #2
igimaster
LQ Newbie
 
Registered: Apr 2005
Posts: 27

Rep: Reputation: 15
well

I'd recommend
awk
sed
grep
for loops
What I recommend is you go to www.tldp.org and read their advanced bash scripting guide. It will have all the info you are looking for when combined with man pages.
danny
 
  


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
Change Text-File through bash script arkus Programming 2 12-17-2004 08:48 PM
Search and replace text in file using shell script? matthurne Linux - Software 2 11-02-2004 10:11 AM
Shell script - how to show a specific line of a text file davi_cabral Linux - Software 3 09-28-2004 01:39 PM
How to delete a line from a text file with shell script programming Bassam General 1 01-28-2004 08:51 PM
how to convert a text file into shell script meng_en Linux - General 9 10-15-2002 10:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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