Sponsored Content
Top Forums Shell Programming and Scripting how Print previous line .......... Post 302343821 by jim mcnamara on Thursday 13th of August 2009 05:50:00 PM
Old 08-13-2009
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print previous, current and next line using sed

Hi, how can i print the previous, current and next line using sed? current line is the matching line. The following prints all lines containing 'Failure' and also the immediate next line cat $file | sed -n -e '/Failure/{N;p;}' Now, i also want to print the previous line too. Thanks,... (8 Replies)
Discussion started by: ysrinu
8 Replies

2. Shell Programming and Scripting

How to use sed to search for string and Print previous two lines and current line

Hello, Can anybody help me to correct my sed syntax to find the string and print previous two lines and current line and next one line. i am using string as "testing" netstat -v | sed -n -e '/test/{x;2!p;g;$!N;p;D;}' -e h i am able to get the previous line current line next line but... (1 Reply)
Discussion started by: nmadhuhb
1 Replies

3. Shell Programming and Scripting

Print the previous line

My requirement is that when ever search criteria matchs in log file, the previous line just above the search word as well as search word should be print. sample log file --03-19T11:26 xxx create version "a.sh@@/main/6" "104157 " --03-18T16:01 xxx create version "a.sh@@/main/5" ... (6 Replies)
Discussion started by: jadoo_c2
6 Replies

4. UNIX for Dummies Questions & Answers

Awk to print data from current and previous line

Hi guys, I have found your forum super useful. However, right now I am stuck on a seemingly "simple" thing in AWK. I have two columns of data, the first column in Age (in million years) and the second column is Convergence Rate (in mm/yr). I am trying to process my data so I can use it to... (2 Replies)
Discussion started by: awk_noob_456
2 Replies

5. Shell Programming and Scripting

Print a field from the previous line

plz help me!! I have this file , 3408 5600 3796 6035 4200 6285 4676 0 40 1554 200 1998 652 2451 864 2728 1200 0 I want it like if $2==0,replace it with field from the previous line+500 say here the o/p would be like 3408 5600 3796 6035 4200 6285... (16 Replies)
Discussion started by: Indra2011
16 Replies

6. Shell Programming and Scripting

print range of lines matching pattern and previous line

Hi all, on Solaris 10, I'd like to print a range of lines starting at pattern but also including the very first line before pattern. the following doesn't print the range starting at pattern and going down to the end of file: cat <my file> | sed -n -e '/<pattern>{x;p;}/' I need to include the... (1 Reply)
Discussion started by: siriche
1 Replies

7. Shell Programming and Scripting

awk script -print line when $2 > $2 of previous line

Hi all, From a while loop I am reading a sorted file where I want to print only the lines that have $1 match and $2 only when the difference from $2 from the previous line is > 30. Input would be like ... AN237 010 193019 0502 1 CSU Amoxycillin AN237 080 ... (2 Replies)
Discussion started by: gafoleyo73
2 Replies

8. Shell Programming and Scripting

How to print previous line of multiple pattern matched line?

Hello, I have below format log file, Comparing csv_converted_files/2201/9747.1012H67126.5077292103609547345.csv and csv_converted_files/22019/97447.1012H67126.5077292103609547345.csv Comparing csv_converted_files/2559/9447.1012H67126.5077292103609547345.csv and... (6 Replies)
Discussion started by: arvindshukla81
6 Replies

9. AIX

Print nth previous line after match

Please help me print nth line after match awk or sed one line command. (3 Replies)
Discussion started by: sushma123
3 Replies

10. UNIX for Beginners Questions & Answers

awk or sed to print the character from the previous line after the regexp match

Hi All, I need to print the characters in the previous line just before the regular expression match Please have a look at the input file as attached I need to match the regular expression ^ with the character of the previous like and also the pin numbers and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies
LAMNODES(1)							     LAM TOOLS							       LAMNODES(1)

NAME
lamnodes - Resolve LAM node/CPU notation to Unix hostnames. SYNOPSIS
lamnodes [-chin] [where] OPTIONS
-c Suppress printing the CPU count for each node. -h Print the command help menu. -i Print IP addresses (instead of IP names) -n Suppress printing CPU count for each node DESCRIPTION
The lamnodes command is used to resolve LAM node/CPU nomenclature to Unix hostnames. It can be used to determine the current running con- figuration of the LAM/MPI run-time environment, and generate a boot schema that can be used to launch LAM in the future. By default, lamnodes will print out the node number, default IP name, CPU count, and per-node flags for each node in the running LAM. gethostbyaddr(3) is used to obtain default hostnames. If gethostbyaddr(3) fails, the IP number is displayed instead. This command can be used by setup shell scripts (and the like) to determine information from a currently-running LAM universe. For exam- ple, use lamnodes to resolve particular CPUs and/or nodes to specific unix hostnames. In a batch environment, lamnodes can be used to determine which CPUs share a common node (note that MPI_GET_PROCESSOR_NAME can be used for a similar effect in an MPI program). lamnodes also shows per-node flags. Currently defined flags are: origin The node where lamboot was executed. this_node The node where lamnodes is running. no_schedule The node will not be used to run MPI and serial processes when N and C are used to mpirun and lamexec. EXAMPLES
lamnodes N -n Display IP names and CPU counts for all nodes. This output can be saved and later used with lamboot(1). lamnodes C -n -c Display the IP name of the nodes containing each CPU, and suppress the LAM node number and CPU count. This output can be saved and later used with lamboot(1). SEE ALSO
bhost(5), gethostbyaddr(3), lamboot(1) LAM 7.1.4 July, 2007 LAMNODES(1)
All times are GMT -4. The time now is 07:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy