LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 06: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, 11:35 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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, 03: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, 04:53 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
sed is a tool that can help you do it.
 
Old 11-02-2004, 02: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



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

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

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