Sponsored Content
Full Discussion: Manipulate file
Top Forums Shell Programming and Scripting Manipulate file Post 302728969 by jim mcnamara on Thursday 8th of November 2012 09:39:34 PM
Old 11-08-2012
You tried it and it does not.

Hmm. very interesting.

This is the output I got (name is newfile )
Code:
================================================================================
=                         System Overview                                      =
================================================================================
Hostname                          : server1
Hostid                            : 84ec6f30
Machine Description               : Sun SPARC Enterprise T5120 server
Serial Number                     : BEL0838M0K
Explorer Collection Date          : 28-Oct-2012 12:39:00 UTC
Machine Architecture              : sparc
OBP Level                         : 4.30.4
KJP Installed Revision            : 147440-19
================================================================================
=                           Withdrawn Patches                                  =
================================================================================
================================================================================
=                           Recommended Patches                                =
================================================================================
148412-02
126206-10
125137-39
149483-01
146470-08
146032-05
146489-06
145006-03
141596-10
149149-01
146486-04
138822-11
137147-07
126546-04
147805-01
147790-01
================================================================================
=                           Security Patches                                   =
================================================================================
119783-25
120272-37
122958-06
147378-02
146666-11
125279-06
149483-01
119059-62
122259-06
118666-40
120185-23
147004-04
146664-02
148601-02
149106-01
================================================================================
=                         Critical Patch Updates                               =
================================================================================
119783-25
126119-02
147159-08
146578-06
149149-01
146232-21
147155-03
149395-01
137080-07
147004-04
119810-07
146664-02
149106-01
================================================================================
=                             ASP Patches                                      =
================================================================================
121308-23
118777-18
146489-06
146578-06
119246-40
119252-35
137097-02
149395-01
================================================================================
=                           Sun/Oracle Alert Patches                           =
================================================================================
120185-23
124672-20
125541-06
147440-25
147805-01
================================================================================
=                        Sun/Oracle Alert Security Patches                     =
================================================================================
120185-23
124672-20
125541-06
147440-25
================================================================================
=              HOST BUS ADAPTERS (HBAs) Found on this System                   =
================================================================================
137137-09
139555-08
141444-09
142909-17
123305-04
123305-04
144112-02
119130-33

This is the input file I used:
Code:
================================================================================
=                         System Overview                                      =
================================================================================
Hostname                          : server1
Hostid                            : 84ec6f30
Machine Description               : Sun SPARC Enterprise T5120 server
Serial Number                     : BEL0838M0K
Explorer Collection Date          : 28-Oct-2012 12:39:00 UTC
Machine Architecture              : sparc
OBP Level                         : 4.30.4
KJP Installed Revision            : 147440-19
================================================================================
=                           Withdrawn Patches                                  =
================================================================================
================================================================================
=                           Recommended Patches                                =
================================================================================
148412-02
126206-10
125137-39
149483-01
146470-08
146032-05
146489-06
145006-03
141596-10
149149-01
146486-04
138822-11
137147-07
126546-04
147805-01
147790-01
================================================================================
=                           Security Patches                                   =
================================================================================
119783-25
120272-37
122958-06
147378-02
146666-11
125279-06
149483-01
119059-62
122259-06
118666-40
120185-23
147004-04
146664-02
148601-02
149106-01
================================================================================
=                         Critical Patch Updates                               =
================================================================================
119783-25
126119-02
147159-08
146578-06
149149-01
146232-21
147155-03
149395-01
137080-07
147004-04
119810-07
146664-02
149106-01
================================================================================
=                             ASP Patches                                      =
================================================================================
121308-23
118777-18
146489-06
146578-06
119246-40
119252-35
137097-02
149395-01
================================================================================
=                           Sun/Oracle Alert Patches                           =
================================================================================
120185-23
124672-20
125541-06
147440-25
147805-01
================================================================================
=                        Sun/Oracle Alert Security Patches                     =
================================================================================
120185-23
124672-20
125541-06
147440-25
================================================================================
=              HOST BUS ADAPTERS (HBAs) Found on this System                   =
================================================================================
137137-09
139555-08
141444-09
142909-17
123305-04
123305-04
144112-02
119130-33

This is the code I ran :
Code:
awk '/^[0-9]/  {var=(index($1,"-")>0) ? $1 : $1 "-" $5; print var ;next}
                      {print $0} '  filename  > newfile

If you want help you should be willing to look at and work with the code. We are not a coding service. AND IMO the code does as you asked.

You just reached the endpoint of my largesse.
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

manipulate csv file to add columns

Hi, I have a csv file with a key composed by 3 columns and some other numeric fields and I need to obtain the partial amounts by some part of the key. This may be some difficult to understand, so better see an example, where my input file is: name,surname,department,y2004,y2005,y2006... (6 Replies)
Discussion started by: oscarmon
6 Replies

2. Shell Programming and Scripting

How do manipulate file path and names

In emacs elisp, there is a handy function called file-name-nondirectory which accepts a path and file name and returns just a file name and extension. There is also a function called file-name-directory which just returns the dire ctory name without the file. How can I implement these same... (2 Replies)
Discussion started by: siegfried
2 Replies

3. Shell Programming and Scripting

sed script to manipulate the /etc/passwd file

Hi. Can anybody help me with a script to extract usernames, shell and home_directory from the /etc/passwd file. I am stuck (2 Replies)
Discussion started by: Pauline mugisha
2 Replies

4. Shell Programming and Scripting

Extract File line and manipulate

How can I print a section of each line in a text file. Eg CODE1 XYR Test2 10319389 CODE2 XYR Test2 10319389 CODE3 XYR Test2 10319389 CODE4 XYR Test2 10319389 CODE5 XYR Test2 10319389 First thing that would be nice would a new file like, awk sed and substring may help but can't figure it... (6 Replies)
Discussion started by: kelseyh
6 Replies

5. Shell Programming and Scripting

Shell script to manipulate a file

Hello, I have a file with following contents : WSL SRVGRP=LISTENER SRVID=2 CLOPT="-A -t -- -n 0x0002aa050a03cc65 " RQPERM=0660 REPLYQ=Y RPPERM=0660 MIN=1 MAX=1 CONV=N I need to print only the value in Hex i.e.... (2 Replies)
Discussion started by: deo_kaustubh
2 Replies

6. UNIX for Dummies Questions & Answers

Manipulate and move columns in a file

Hello Unix Gurus, I have a request 2 perform several functions on a file, delete columns, delete rows based on column value, and finally move around columns in the final output. Consider the following input file with 12 columns; ... (1 Reply)
Discussion started by: chumsky
1 Replies

7. Shell Programming and Scripting

Find string in one file and manipulate other

hi, I have 2 files delimited by "|" File 1: 1|28|ABC|11|9620034||XXX555| 29|22|ABC|11|9620258||XXX555| 51|26|ABC|11|9620314||XXX555| 77|20|ABC|11|9630506||XXX555| 97|36|ABC|11|9630562||XXX555| File 2: 9620028|I 9620034|I 9620314|S 9620332|I 9620258|I 9630506|S 9630562|S (3 Replies)
Discussion started by: pparthiv
3 Replies

8. Shell Programming and Scripting

nawk script to manipulate txt file

Hi experts, I am not familiarised using nawk/awk to manipulate txt file. So I need ur help here. thanks. txt1 - qc_m.log TQC101 TQC102 TQC103 TQC104 txt2 - resultEqpt.log TQC102,,LOGOFF TQC103,,LOGOFF TQC104,2012-10-03 07:42:57,LOGON so TQC101 is not found in txt 2. ... (15 Replies)
Discussion started by: ment0smintz
15 Replies

9. Shell Programming and Scripting

Manipulate a CSV File

Hello, How do i manipulate .csv file to this format? Thank you very much. Source: john,5 marco,7 john,4 paul,3 marco,8 Output: john,9 marco,15 (5 Replies)
Discussion started by: tara123
5 Replies

10. Shell Programming and Scripting

Manipulate the text file in UNIX

Hi All, I have a file like below and i have 2 questions on this (They are 3 lines starts with 01 , 02 and 03. but is 01abc333644554 234 2334535 34534535355353 sfsdf345455 353 4543 jgkg tty 7676 02cdesdfsdfsdf 234 wesdfsdf 345345 234234 234234 2342342 dfgdfg sdfgg dgdgdg fgvfs... (6 Replies)
Discussion started by: siva.pitchai
6 Replies
All times are GMT -4. The time now is 10:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy