Sponsored Content
Top Forums Shell Programming and Scripting Grep a string and print a string from the line below it Post 302328018 by rakeshawasthi on Tuesday 23rd of June 2009 07:31:36 AM
Old 06-23-2009
Everytime we interact I ask you to show your efforts Smilie
Code:
awk '/Age: 3/{getline;FS=":";print $2}' inputfile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

print only matched string instead lines in grep

frnd, Is there any way to print only the string that matched the pattern instead printing the whole line? thanks in advance. (3 Replies)
Discussion started by: clx
3 Replies

2. Shell Programming and Scripting

Find a string using grep & print the line above or below that.

Hi All, Please tell me how can I Find a string using grep & print the line above or below that in solaris? Please share as I am unable to use grep -A or grep -B as it is not working on Solaris. (10 Replies)
Discussion started by: Zaib
10 Replies

3. Shell Programming and Scripting

grep a string and print strings on that line

i have a file like below ABS 12234 A C 12G CFY 23865 A C 34D i want to grep "A C" then print ABS 12G 12234 CFY 34D 23865 Thanks! (4 Replies)
Discussion started by: kingpeejay
4 Replies

4. Shell Programming and Scripting

grep on string and printing line after until another string has been found

Hello Everyone, I just started scripting this week. I have no background in programming or scripting. I'm working on a script to grep for a variable in a log file Heres what the log file looks like. The x's are all random clutter xxxxxxxxxxxxxxxxxxxxx START: xxxxxxxxxxxx... (7 Replies)
Discussion started by: rxc23816
7 Replies

5. Shell Programming and Scripting

Grep a string and write a value to next line of found string

Hi, I have two variables x and y. i need to find a particular string in a file, a workflow name and then insert the values of x and y into the next lines of the workflow name. basically it is like as below wf_xxxxxx $$a= $$b= $$c= figo $$d=bentley i need to grep the 'wf_xxxx' and then... (6 Replies)
Discussion started by: angel12345
6 Replies

6. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

7. Shell Programming and Scripting

Grep for the string and then print the next 4 lines

RHEL 5.8 I have a text file like below. I want to grep for a string and then print the next 4 lines including the line with the string I grepped for For eg: I want grep for the string HANS and then print the next 4 lines including HANS $ cat someText.txt JOHN NATIONALITY:... (7 Replies)
Discussion started by: omega3
7 Replies

8. Shell Programming and Scripting

String search and print next all lines in one line until blank line

Dear all I want to search special string in file and then print next all line in one line until blank lines come. Help me plz for same. My input file and desire op file is as under. i/p file: A1/EXT "BSCABD1_21233G1" 757 130823 1157 RADIO X-CEIVER ADMINISTRATION BTS EXTERNAL FAULT ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

9. Shell Programming and Scripting

Need to print the next word from the same line based on grep string condtion match.

I need to fetch particular string from log file based on grep condition match. Actual requirement is need to print the next word from the same line based on grep string condtion match. File :Java.lanag.xyz......File copied completed : abc.txt Ouput :abc.txt I have used below... (5 Replies)
Discussion started by: siva83
5 Replies

10. Shell Programming and Scripting

Grep command to search a regular expression in a line an only print the string after the match

Hello, one step in a shell script i am writing, involves Grep command to search a regular expression in a line an only print the string after the match an example line is below /logs/GRAS/LGT/applogs/lgt-2016-08-24/2016-08-24.8.log.zip:2016-08-24 19:12:48,602 ERROR... (9 Replies)
Discussion started by: Ramneekgupta91
9 Replies
paste(1)						      General Commands Manual							  paste(1)

NAME
paste - Joins corresponding lines of several files or subsequent lines in one file SYNOPSIS
paste [-d list] [-s] file... STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: paste: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Replaces the delimiter that separates lines in the output (tab by default) with one or more characters from list. If list contains more than one character, then the characters are repeated in order until the end of the output. In parallel merging, the lines from the last file always end with a newline character, instead of one from list. The following special characters can be used in list: Newline character Tab Backslash Empty string (not a null character) [Tru64 UNIX] An extended character You must quote characters that have special meaning to the shell. Merges all lines from each input file into one line of output (serial merging). Using this option, the paste command merges all lines in the first input file forcing a newline before at the end. The command then continues with the next input file, continuing in the same manner until all input files have been completed. A tab separates the input lines unless you use the -d option. Regardless of the list, the last character of the output is a newline character. OPERANDS
The name of an input file. You may specify up to 12 files, including hyphens. If you specify a -, paste reads standard input recursively, one line for each -. DESCRIPTION
Specifying the -d option or no options causes the paste command to treat each file as a column, joining them horizontally with a tab char- acter by default (parallel merging). Using the -s option, the paste command combines all lines of each input file into one output line (serial merging). These lines are joined with the tab character by default. Output lines can be any length. [Tru64 UNIX] The output of pr -t -m is similar to the output produced by the paste command, but pr with its options creates extra spaces, tabs, and lines for an enhanced page layout. RESTRICTIONS
If the -s option is not used, it is an error if any specified file cannot be opened. EXIT STATUS
The following exit values are returned: Successful completion. An error occurred. EXAMPLES
To paste several columns of data together, enter: paste names places dates > npd This creates a file named npd that contains the data from names in one column, places in another, and dates in a third. The columns are separated by tab characters. File npd then contains: rachel New York 28 February jerzy Warsaw 27 April mata Nairobi 21 June michel Boca Raton 27 July segui Managua 18 November A tab character separates the name, place, and date on each line. To separate the columns with a character other than a tab (sh only), enter: paste -d"!@" names places dates > npd This alternates the apostrophe (!) and the at sign (@) as the column separators. If names, places, and dates are the same as in Example 1, then npd contains: rachel!New York@28 February jerzy!Warsaw@27 April mata!Nairobi@21 June michel!Boca Raton@27 July segui!Managua@18 November To dis- play the standard input in multiple columns, enter: ls | paste - - - - This lists the current directory in four columns. Each hyphen (-) tells the paste command to create a column containing data read from the standard input. The first line is put in the first column, the second line in the second column, ... and then the fifth line in the first column, and so on. This is equivalent to ls | paste -d" " -s - which fills the columns across the page with subsequent lines from the standard input. The -d defines the character to insert after each column: a tab character ( ) after the first three columns, and a newline character ( ) after the fourth. Without the -d option, paste -s - displays all of the input as one line with a tab between each column. To merge the lines of the file names above into one output line, enter: paste -s names This results in: rachel jerzy mata michel segui ENVIRONMENT VARIABLES
The following environment variables affect the execution of paste: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments and input files). Determines the locale for the format and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: cut(1), grep(1), fold(1), join(1), pr(1) Standards: standards(5) paste(1)
All times are GMT -4. The time now is 07:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy