LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-06-2009, 04:49 AM   #1
guptneelam
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
Help with scripting


I have a file say File1.Now i need a specific pattern from the lines to be added to the other line.

File

red
blue
green
ABC.txt@ABC
END
black
ash
grey
purple
XYZ.txt@XYZ
orange
pink
yellow
marroon
PQR.txt@PQR

Now i want the file to look like this<br>

#change ABC
red
blue
green
ABC.txt@ABC
END
#change XYZ
black
ash
grey
purple
XYZ.txt@XYZ
END
#change PQR
orange
pink
yellow
marroon
PQR.txt@PQR
END

Last edited by guptneelam; 03-06-2009 at 04:50 AM.
 
Old 03-06-2009, 05:53 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
This reeks of homework.
 
Old 03-06-2009, 05:57 AM   #3
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
You mean put #change ABC at the front and END at the end??

Something like:
Code:
cat "#change ABC" file1 > file2
cat file2 "END" > file3
??

This probably won't work, I'm just trying to illustrate the concatenation idea.

Hope helps.
 
Old 03-06-2009, 06:23 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I agree that this looks like homework. Regardless, you need to give some context for the question, and you need to state the problem completely. You show an example output file, but you don't state the rule to be followed---ie the criteria for where to insert something and what to insert.

What utilities are you familiar with--eg SED, AWK, TR?

If homework, tell us more about the class, the books you are using, etc.
 
  


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
scripting help ksri07091983 Linux - Server 2 04-14-2008 05:15 AM
Need scripting help!! stan0934 Programming 5 05-29-2006 01:29 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
Looking for scripting Help steve_f60 Linux - General 3 03-22-2005 12:45 PM
Need Help on Scripting wongedan Linux - Newbie 2 08-23-2004 08:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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