i've got a script based on queries which generates this output into a file
I'm finding it a bit hard in order to try to do another script which opens this file and present the output in the following format:
I tried to play a bit with grep and awk, but i don't want to specifically grep any string from the first row since they may increase by time, making the grep static (i.e. by time the script needs to be altered to add the new string in grep.
...
...
I tried to play a bit with grep and awk, but i don't want to specifically grep any string from the first row since they may increase by time, making the grep static (i.e. by time the script needs to be altered to add the new string in grep.
can you kindly shed some light?
It looks like you have to perform the same set of steps on each line.
Take, for example, this line:
1) Split it on the "|" character, to get the following tokens:
2) Now use tokens 1, 3 and 4 to form this string:
3) And append it to another "output" string (i.e. a string that you will print once you are done processing your entire file.)
Keep doing steps 1), 2) and 3) for all lines you go through.
In the end, print the "output" string.
Here's a Perl implementation, in case Perl is an option for you.
The -F modifier specifies the character "|" to split the line on.
Your perl one liner is excellent. I only just modified it since now the output needs to be slightly different from what i presented previously and it worked.
I'm finding it a bit hard in order to try to do another script which opens this file
A word of caution: UNIX text files (and the utilities working on them) are line-oriented. That means these utilities don't read from a file or input stream basically one character at a time, but they read in chunks. These chunks are series of characters separated by newline ("\n") characters ("lines").
If the line you construct gets too long (it depends on your system how long "too long" is, have a look in the kernel headers) you might eventually get a "line too long" error.
Note that it is possible to read from a file byte-based (that is: a certain number of bytes at a time, not caring about line separators), but this cannot be done in (shell) scripts using only standard methods.
Hello Everyone,
I have a sample file raw.txt as shown below :
Drive Bays
Bay Name : SD-2C
Number of Standby Power Supplies : 4
Number of Drive Enclosures : 12
Summary Status of Contained Modules
All... (6 Replies)
Hello Team,
I have the following details in a txt file (please note the spaces and tabs)
C1 C2 C3
------------------ --------------- -------------
abc, xyz 2 8
pqr 2 ... (9 Replies)
I have written some scripts that resulted in the table below (Column1 is ITEM, Column2 is Group, Column3 is Category and Column4 is Quantity) but I want the output in another format:
Input:
K123 X CATA 3
K123 Y CATA 4
K123 Z CATA 2
K123 X CATB 5
K123 Y CATB 2
K123 Z CATB 2
B65 M CATB... (7 Replies)
Hi ,
i am generating some data by firing sql query with connecting to the database by my solaris box.
The below one should be the header line of my excel ,here its coming in separate row.
TO_CHAR(C. CURR_EMP_NO
---------- ---------------
LST_NM... (6 Replies)
Hi Following is the assumed input...
Symmetrix ID : 12345
Originator Port wwn : 123456789
User-generated Name : 123456789/123456789
Sym Dev Dir:P LUN
------ ----- ----------------------- ---- --- ---- ---- ---- -------
1234 ... (4 Replies)
Hi,
I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format.
Example:
File.txt
AP|{SSHA}VEEg42CNCghUnGhCVg==
APVG3|{SSHA}XK|"password"
AP3|{SSHA}XK|"This is test"
....
etc
---------
test.sh has... (1 Reply)
Dear all,
I have written a program which access database and displays the values returned by the query . There are 10 columns to be displayed in one row. But am ending with 5 lines displayed on 1st line and the next 5 in the 2nd line.
Ex :
21608 10-20-2007 148 Al's Appliance... (7 Replies)
Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command isecho date
`top -b -n1 | grep -e Cpu -e Mem` I get the output in 3 separate lines.Tue Feb 24 15:00:03
Cpu(s): 3.4% us, 8.5% sy .. ..
Mem: 1011480k total, 226928k used, ....... (4 Replies)
I have a text file that I want a script to parse and grab only the relavent stuff.
No idea where to start..
This is the text file.212 0.00000 ? -> (multicast) ETHER Type=2000 (Unknown), size = 344 bytes
0: 0100 0ccc cccc 000b 5f95 0fbe 014a aaaa ........_....J..... (7 Replies)