LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-06-2004, 07:52 AM   #1
vinoj
LQ Newbie
 
Registered: Oct 2004
Location: Bangalore, India
Posts: 3

Rep: Reputation: 0
editing multiple files in linux?


Hi,

I am new to programming (shell). I work usually with the bash or t(csh) shell in linux. I do some work which requires handling numerous text files. eg: file1, file2, file3....file'n'. In these 'n' number of files i would like to,
1. Find for a certain number or character and replace it in all the n number of files.
2. Go to a specific line and make changes in it!

Is there any method or trick to do this by writing a shell script?

Thanks in advance!
regards,
vinoj
 
Old 10-06-2004, 12:35 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
In your step 2. do you want to edit en certain line interactively with an editor, or the the change known beforehand? Also you need to know its line-number or the text the line you want to edit should contain.

Anyhow, yes, this can be done in a shell script.

Is this home-work?
 
Old 10-30-2004, 04:59 AM   #3
vinoj
LQ Newbie
 
Registered: Oct 2004
Location: Bangalore, India
Posts: 3

Original Poster
Rep: Reputation: 0
Hi Hko,

I am glad to receive ur reply. In step 2, I would like to find a known character or number in the a specified line (known) and change it non-interactively. The changes are known beforehand!. I require to run a certain program with different input files. I want to non-interactively enter the file. edit the file name and then run the program. It continues till the 'n' th file which are available.

It is not a home work, it is part of my work which i would like to automate rather than doing things manually. I am a graduate student and am new to linux and shell scripting.

Thanks for your reply.
regards,
vinoj
 
Old 10-30-2004, 05:53 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Tribblix, Ubuntu/WSL
Posts: 9,768

Rep: Reputation: 468Reputation: 468Reputation: 468Reputation: 468Reputation: 468
sed is a tool that can help you do it.
 
Old 11-02-2004, 03:31 AM   #5
vinoj
LQ Newbie
 
Registered: Oct 2004
Location: Bangalore, India
Posts: 3

Original Poster
Rep: Reputation: 0
Hi,

Thanks a lot... sed indeed worked!

regards,
vinoj
 
  


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
Editing .PDF or .(E)PS files in Linux? 95se Linux - Software 13 02-08-2006 10:33 PM
What archiving app for Linux will do multiple files of the same name from X? t3gah Linux - Software 3 03-19-2005 05:42 AM
Why when editing files does Linux create a duplicate file with a ~ in the extension? bugbite99 Linux - General 6 01-17-2005 03:21 PM
Editing PDF Files in Linux jomy Linux - Software 1 11-21-2004 08:28 AM
batch editing multiple lines statmobile Programming 8 09-16-2004 09:05 PM

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

All times are GMT -5. The time now is 04:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration