Modify the file with awk,sed or perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Modify the file with awk,sed or perl
# 1  
Old 06-19-2012
Modify the file with awk,sed or perl

Hi All,
I need help from any of you.Would be so thankful for your help.

I/P

Code:
DDDD,1045,161,1557,429,1694,800,1911,1113,2460,1457,2917>
1609,3113,1869,3317,2732,3701,3727,4132,5857,5107>
9004,6496
DDDD,1125,157,1558,429,1694,800,1911,1117,2432,1444,2906>
1776,3296,2373,3549,2732,3701,3727,4132,5857,5107>

O/P

Code:
DATE:19/06/2011 ,UPDATED JUST NOW......
YEAR-2012
DDDD,1045,161,1557,429,1694,800,1911,1113,2460,1457,2917>
1609,3113,1869,3317,2732,3701,3727,4132,5857,5107>
9004,6496
DATE:19/06/2011 ,UPDATED JUST NOW......
YEAR-2012
DDDD,1125,157,1558,429,1694,800,1911,1117,2432,1444,2906>
1776,3296,2373,3549,2732,3701,3727,4132,5857,5107>

So I would like to modify my I/P lines as with
Code:
DATE:19/06/2011 ,UPDATED JUST NOW......
YEAR-2012

preceeding the line starting with DDDD.and on every occasion it encounters a line starting with DDDD


THanks in advance
best regards

Moderator's Comments:
Mod Comment Please view this link: How to use [code]...[/code] tags

Last edited by Scrutinizer; 06-19-2012 at 07:43 AM.. Reason: code tags
# 2  
Old 06-19-2012
Code:
$ sed 's|^DDDD|DATE:19/06/2011 ,UPDATED JUST NOW......\
YEAR-2012\
DDDD|' inputfile

# 3  
Old 06-19-2012
Hi Balajesuri,
Thanks alot
Can you please tell me if I want to print something like
!!DATE:19/06/2011 ,UPDATED JUST NOW......
!!YEAR-2012

,then how I need to modify ur script

Just introducing !!.

Thanks in advance

---------- Post updated at 06:07 AM ---------- Previous update was at 06:07 AM ----------

Hi Balajesuri,
Thanks alot
Can you please tell me if I want to print something like
!!DATE:19/06/2011 ,UPDATED JUST NOW......
!!YEAR-2012

,then how I need to modify ur script

Just introducing !!.

Thanks in advance

---------- Post updated at 06:22 AM ---------- Previous update was at 06:07 AM ----------

HI Balajesuri
please ignore my previous question,I have figured it out.
Thanks for your help

---------- Post updated at 06:22 AM ---------- Previous update was at 06:22 AM ----------

HI Balajesuri
please ignore my previous question,I have figured it out.
Thanks for your help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Sed, awk or another bash command to modify string with the content of another file

Hello everybody, I would like modify some strings using sed or another command line with the content file. For example: - {fqdn: "server-01" , ip: "server-01"} - {fqdn: "server-02" , ip: "server-02"} - {fqdn: "server-03" , ip: "server-03"} - {fqdn: "server-04" , ip: "server-04"} My... (4 Replies)
Discussion started by: dco
4 Replies

2. Shell Programming and Scripting

Using awk and sed to modify a create sql script

Hi, I have a file which contains the following data claim_src|clm_id,typ_id pat_src|pat_id prov_src|prov_id,clm_id,prov_name The first field is table name and second field is primary keys of the table Now I have three files which contain ddl of each table. clam_src.sql... (4 Replies)
Discussion started by: wahi80
4 Replies

3. Shell Programming and Scripting

Modify xml using sed or awk

Hi All, I want to modify(changing the status from "on" to "off" status of Stage-element value from the below xml file using sed or awk: File Name: global.xml <?xml version="1.0" encoding="UTF-8"?> <config> <widget> <name>HTTP-POOL</name> <attributes> ... (5 Replies)
Discussion started by: wamqemail2
5 Replies

4. Shell Programming and Scripting

Modify text file using sed

Hello all, I have some text files I need to do the following on: Delete banner page (lines 1-56) --I am doing this using sed Remove ^M --I am doing this using vi Remove trailer page --this can vary based on the contents of the file, it usually starts with *************************** I am... (5 Replies)
Discussion started by: jeffs42885
5 Replies

5. Shell Programming and Scripting

awk, sed or perl regexp to print values from file

Hello all According to the following file (orignal one contains 200x times the same structure...) I was wondering if someone could help me to print <byte>??</byte> values example, running this script/command like ./script.sh xxapp I would expect as output: 102 116 112 ./script.sh xxapp2... (2 Replies)
Discussion started by: cabrao
2 Replies

6. Shell Programming and Scripting

Using sed (or awk or perl) to delete rows in a file

I have a Unix file with 200,000 records, and need to remove all records from the file that have the character ‘I' in position 68 (68 bytes from the left). I have searched for similar problems and it appears that it would be possible with sed, awk or perl but I do not know enough about any of these... (7 Replies)
Discussion started by: joddo
7 Replies

7. Shell Programming and Scripting

reformatting xml file, sed or awk I think (possibly perl)

I have some xml files that cannot be read using a standard parser, or I am using the wrong parser. The issues seems to be spaces in some of the tags. Here is a sample,<UgUn 2 > <Un> -0.426753 </Un> </UgUn>The parser isn't able to find the number 2, so that information is lost, etc. It seems... (16 Replies)
Discussion started by: LMHmedchem
16 Replies

8. Shell Programming and Scripting

Sed or Awk for modify hour in a crontab AIX

Hi, I want to modifiy the hour in the crontab AIX 5.3 for this line: Input: 00 22 * * * /outillage/script_exploit/bin/SavOffline.ksh > /dev/null 2>&1 Output: 30 20 * * * /outillage/script_exploit/bin/SavOffline.ksh > /dev/null 2>&1 With the awk or sed function through a ssh -q... (1 Reply)
Discussion started by: khalidou13
1 Replies

9. Shell Programming and Scripting

awk, sed, perl assistance in outputting formatted file

Hello, Please advise. Scoured this site, as well as google for answers. However if you do not know what to search for, it's a bit hard to find answers. INPUT: ACTASS= 802 BASECOS= 279 COSNCHG= 3 CUSCOS= 52 UPLDCOS= 2 DESIRED OUTPUT: ACTASS=802 BASECOS=279 (13 Replies)
Discussion started by: abacus
13 Replies

10. Shell Programming and Scripting

modify and use awk sed program

The following awk script creates a file b.dat. awk '{print substr($0,1,27),substr($2,index($2,"_")+1)," ",substr($0,49)}' a.dat > b.dat I need this script to be modified to also sum $3 values by distinct $1 and $2 fields. Current file W2_2009275 2 8 W2_2009275 2 7 W1_2009275 1... (3 Replies)
Discussion started by: mnnarendra
3 Replies
Login or Register to Ask a Question