Sponsored Content
Top Forums Shell Programming and Scripting Printing multiple lines on the same line between specific text Post 302959548 by kieranfoley on Wednesday 4th of November 2015 10:58:49 AM
Old 11-04-2015
Printing multiple lines on the same line between specific text

This is an extract from a large file. The lines that start with fc are ports on a fabric switch. In between each fc port there is information about the port.

Code:
fc2/12 is up
    Port description is SEIEDISCOVER-3
    Speed is 4 Gbps
fc2/13 is down (Administratively down)
fc2/14 is up
    Port description is SEIEADB51
    Speed is 4 Gbps
fc1/6 is down (Link failure or not-connected)
    Port description is SEIDEVAS18
fc2/15 is up
    Port description is UCS02-POD1-A 4/5
    Speed is 8 Gbps
    Belongs to port-channel 3

I want to be able to be able to print certain pieces of information for every fc port on the same line. So I would like the output to look like this. If a port is down then I want to skip to the next port that is up.

Code:
fc2/12 SEIEDISCOVER-3 4GB
fc2/14 SEIEADB51 4GB
fc2/15 UCS02-POD1-A 4/5 8GB port-channel 3

Is there a way to do this using awk? I appreciate any help on this.

---------- Post updated at 03:58 PM ---------- Previous update was at 02:59 PM ----------

I have figured this out from looking at other posts.

Code:
awk 'NF&&$1=RS$1'  RS="fc"

get me everything in one line in between each fc and from this I am able filter out the info I need.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing lines with specific awk NF

I have this files: ./frm/lf_mt1_cd.Ic_cell_template.attr ./die/addgen_tb_pumd.Ic_cell_template.attr ./min_m1_n.Ic_cell_template.attr When I use: awk -F\/ '{print NF}' Would result to: 3 3 2 I would like to list the files with 3 fields on it. Any Suggestions? (1 Reply)
Discussion started by: jehrome_rando
1 Replies

2. Shell Programming and Scripting

How to replace specific text line out of multiple occurance

Hi I would like to replace specific line eg ExitAction = NONE to ExitAction = FALSE under only TASK sipsiproc and other ExitAction = NONE will remain as usual in the file(shell script) The file contains: TASK rgcdproc { CommandLine = $SSHOME/bin/rgcd.exe NewConsole... (5 Replies)
Discussion started by: madhusmita
5 Replies

3. Shell Programming and Scripting

extract the lines between specific line number from a text file

Hi I want to extract certain text between two line numbers like 23234234324 and 54446655567567 How do I do this with a simple sed or awk command? Thank you. ---------- Post updated at 06:16 PM ---------- Previous update was at 05:55 PM ---------- found it: sed -n '#1,#2p'... (1 Reply)
Discussion started by: return_user
1 Replies

4. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

5. Shell Programming and Scripting

Printing several lines of a file after a specific expression

Hello, I want to print a number of lines of a file after a specific expression of a line. I have this sed command but it prints only 1 line after the expression. How could I adapt it to print for instance 10 lines after or 15 lines after ? sed -n '/regexp/{n;p;}' Thx & Regs, Rany. (5 Replies)
Discussion started by: rany1
5 Replies

6. Shell Programming and Scripting

Printing all lines before a specific string and a custom message 2 lines after

Hello all, I need to print all the lines before a specific string and print a custom message 2 lines after that. So far I have managed to print everything up the string, inclusively, but I can't figure out how to print the 2 lines after that and the custom message. My code thus far is:... (4 Replies)
Discussion started by: SEinT
4 Replies

7. Shell Programming and Scripting

how to Insert values in multiple lines(records) within a pipe delimited text file in specific cols

this is Korn shell unix. The scenario is I have a pipe delimited text file which needs to be customized. say for example,I have a pipe delimited text file with 15 columns(| delimited) and 200 rows. currently the 11th and 12th column has null values for all the records(there are other null columns... (4 Replies)
Discussion started by: vasan2815
4 Replies

8. Shell Programming and Scripting

Combine multiple unique lines from event log text file into one line, use PERL or AWK?

I can't decide if I should use AWK or PERL after pouring over these forums for hours today I decided I'd post something and see if I couldn't get some advice. I've got a text file full of hundreds of events in this format: Record Number : 1 Records in Seq : ... (3 Replies)
Discussion started by: Mayday22
3 Replies

9. UNIX for Dummies Questions & Answers

Printing lines with specific strings at specific columns

Hi I have a file which is tab-delimited. Now, I'd like to print the lines which have "chr6" string in both first and second columns. Could anybody help? (3 Replies)
Discussion started by: a_bahreini
3 Replies

10. Shell Programming and Scripting

Delete lines above and below specific line of text

I'm trying to remove a specific number of lines, above and below a specific line of text, highlighted in red: <STMTTRN> <TRNTYPE>CREDIT <DTPOSTED>20151205000001 <TRNAMT>10 <FITID>667800001 <CHECKNUM>667800001 <MEMO>BALANCE </STMTTRN> <STMTTRN> <TRNTYPE>DEBIT <DTPOSTED>20151207000001... (8 Replies)
Discussion started by: bomsom
8 Replies
IBDIAGPATH(1)						       IB DIAGNOSTIC PACKAGE						     IBDIAGPATH(1)

NAME
ibdiagpath - IB diagnostic path SYNOPSYS
ibdiagpath {-n <[src-name,]dst-name>|-l <[src-lid,]dst-lid>|-d <p1,p2,p3,...>} [-c <count>] [-v] [-t <topo-file>] [-s <sys-name>] [-i <dev-index>] [-p <port-num>] [-o <out-dir>] [-lw <1x|4x|12x>] [-ls <2.5|5|10>] [-pm] [-pc] [-P <<PM counter>=<Trash Limit>>] DESCRIPTION
ibdiagpath traces a path between two end-points and provides information regarding the nodes and ports traversed along the path. It uti- lizes device specific health queries for the different devices along the traversed path. The way ibdiagpath operates depends on the addressing mode used on the command line. If directed route adressing is used, the local node is the source node and the route to the des- tination port is known apriori. On the other hand, if LID route (or by-name) addressing is imployed, then the source and destination ports of a route are specified by their LIDs (or by the names defined in the topology file). In this case, the actual path from the local port to the source port, and from the source port to the destination port, is defined by means of Subnet Management Linear Forwarding Table queries of the switch nodes along those paths. Therefore, the path cannot be predicted as it may change. The tool allows omitting the source node, in which case the local port on the machine running the tool is assumed to be the source. Note: When ibdiagpath queries for the perfor- mance counters along the path between the source and destination ports, it always traverses the LID route, even if a directed route is specified. If along the LID route one or more links are not in the ACTIVE state, ibdiagpath reports an error. Checks for path validity from partitions, IPoIB and QoS perspectives are also provided. ibdiagpath.log - A dump of all the application reports generate according to the provided flags ibdiagnet.pm - A dump of the pm Counters values, of the fabric links OPTIONS
-n <[src-name,]dst-name> : Names of the source and destination ports (as defined in the topology file; source may be omitted -> local port is assumed to be the source) -l <[src-lid,]dst-lid> : Source and destination LIDs (source may be omitted -> local port is assumed to be the source) -d <p1,p2,p3,...> : directed route from the local node (which is the source) and the destination node -c <count> : The minimal number of packets to be sent across each link (default = 100) -v : Enable verbose mode -t <topo-file> : Specifies the topology file name -s <sys-name> : Specifies the local system name. Meaningful only if a topology file is specified -i <dev-index> : Specifies the index of the device of the port used to connect to the IB fabric (in case of multiple devices on the local system) -p <port-num> : Specifies the local device's port number used to connect to the IB fabric -o <out-dir> : Specifies the directory where the output files will be placed (default = /tmp) -lw <1x|4x|12x> : Specifies the expected link width -ls <2.5|5|10> : Specifies the expected link speed -pm : Dump all the fabric links, pm Counters into ibdiagnet.pm -pc : Reset all the fabric links pmCounters -P <PM=<Trash>> : If any of the provided pm is greater then its provided value, print it to screen -h|--help : Prints the help page information -V|--version : Prints the version of the tool --vars : Prints the tool's environment variables and their values ERROR CODES
1 - The path traced is un-healthy 2 - Failed to parse command line options 3 - More then 64 hops are required for traversing the local port to the "Source" port and then to the "Destination" port. 4 - Unable to traverse the LFT data from source to destination 5 - Failed to use Topology File 6 - Failed to load required Package IBDIAG 1.0 2009-01-08 IBDIAGPATH(1)
All times are GMT -4. The time now is 06:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy