Parsing a file using unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing a file using unix
# 8  
Old 10-23-2010
Code:
awk '/^\$AGE/{print gensub(/\//, FS ,"g",$1)}' infile

# 9  
Old 10-23-2010
Note: gensub=gawk
# 10  
Old 10-24-2010
using Perl:-


Code:
perl -wlne 's#\/#\t\t#g , print  if /^\$/ ;' infile.txt

# 11  
Old 10-24-2010
hi
u can try this one also


Code:
cat file | grep '^$' | sed 's/\(.*\/\)\(.*[[:blank:]]\)\(.*$\)/\1     \2/' | sed 's/\///'


Last edited by Scott; 10-24-2010 at 08:57 AM.. Reason: Code tags, PLEASE!
# 12  
Old 10-24-2010
more simple way Smilie
Code:
# sed -n '/^\$/s/\(.*\)\/\([^ ]*\).*/\1\t\2/p' infile

# 13  
Old 10-25-2010
Hi,

Another 'sed' solution:
Code:
# script.sed

1 {
    ## Put 24 spaces in hold buffer.
    x
    s/^$/ / ; s/ */&&&&&&/ ; s/ */&&&&/ 
    x
}

/^\$/ {
    ## Remove words after first blank found.
    s/^\([^ ]*\).*/\1/
    ## Change order. Put spaces just after the part before the '/' character.
    G
    s/\(.*\)\/\(.*\)\n\([ ]*\)/\1\3\/\2/
    ## Take 24 leading characters, including spaces, and concatenate with rest of line.
    s/^\(.\{24\}\) *\/\(.*\)/\1\2/
    p
}

Code:
sed -n -f script.sed infile

Regards,
Birei
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Parsing UNIX emails

Hi all, I am new to unix and I have a requirement to develop a shell script which does the following:- Check for email from a particular user If found, copy the attachment in the mail to a particular directory. Delete the email. Any help, pointers are really appreciated. Thanks (3 Replies)
Discussion started by: esgovi1234
3 Replies

2. Shell Programming and Scripting

Specific string parsing in Linux/UNIX

Hi, I have a string which can be completely unstructred. I am looking to parse out values within that String. Here is an example <Random Strings> String1=<some number a> String2=<some number b> String3=<some number c> Satish=<some number d> String4=<some number e> I only want to parse out... (1 Reply)
Discussion started by: satishrao
1 Replies

3. Windows & DOS: Issues & Discussions

Parsing a UNIX txt to separate files

I have a requirement to parse a dataflex .txt file and break it into separate files within the Windows server env. Is there any special characters I should pay particular attention on the unix side? Any ideas? Thanks in advance (2 Replies)
Discussion started by: kicklinr
2 Replies

4. UNIX for Advanced & Expert Users

XML parsing by UNIX

Hi, I am new in shell scripting. i want to extract tag values in xml files by using shell script. my files like this: <cw: properties> <cw:std_properties> <tns: properties> <tns:name>AdminOutQueue</tns:name> <tns:type>String</tns:type> <tns:subtype>QueueName</tns:subtype> <tns:value... (25 Replies)
Discussion started by: arindam guha
25 Replies

5. Shell Programming and Scripting

New to UNIX ... Date parsing

Hi ... extremely new to Unix scripting ... I have to get a date field from mm/dd/yyyy to yyyy/mm/dd format ... I have a variable that I want parsed. I don't seem to be doing it right?? Thanks. (19 Replies)
Discussion started by: MJKeeble
19 Replies

6. Shell Programming and Scripting

string parsing using UNIX

I got multple sql files.such as >>vi abc.sql select A.SITENAME, NULL NULL A.CREATE_DTM NULL A.MODIFY_DTM NULL FROM ${STG_RET_ITEM} A INNER JOIN ${STG_INC_COMP} B ON (A.CUSTID=B.CUSTID) LEFT OUTER JOIN ( select C.SITEID,SITESTATUS,MIN_EFF_DT,CURR_ST_DT,MAX_IN_DT,MAX_ACT_DT from... (4 Replies)
Discussion started by: ali123
4 Replies

7. Shell Programming and Scripting

File parsing in Unix

I have got a large file with content as below. LOCATION A B C 1 Line 3 Line 4 *Line 8 **Line 9 TAG END LOCATION A B" C 3 Line 33 Line 34 (4 Replies)
Discussion started by: rinku11
4 Replies

8. Programming

Parsing unix STAT structure

Hi I am creating a utility which needs to create a log file under the path represented by an environment variable. The condition is that this path must be a valid DIRECTORY PATH. So i need to determine that the path is indeed a VALID DIRECTORY PATH. I have written a function which will return... (2 Replies)
Discussion started by: skyineyes
2 Replies

9. UNIX for Advanced & Expert Users

html parsing using unix

hi all, I had raised the same question a few weeks back but forgot to mention a lot of points ... so i am raising a new thread furnishing my requirement ... sorry for that .... here is my problem. i have a html that look like below <tr class="modifications-oddrow"> <td... (2 Replies)
Discussion started by: sais
2 Replies

10. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies
Login or Register to Ask a Question