Sponsored Content
Top Forums Shell Programming and Scripting Returning two lines if they both match strings Post 302865423 by majormajormajor on Friday 18th of October 2013 12:05:49 PM
Old 10-18-2013
beautiful, thankyou.

two quick further questions, if you don't mind Smilie

1 - how do i run awk recursively on a directory? i have 100s of files in a directory which i need to run this on.
2 - i also need it to dump the filename at the beginning of each line.

grep was handy with this in that the -A flag dumps the filename with the output. not sure with awk...

thanks a million though!

Last edited by majormajormajor; 10-18-2013 at 01:11 PM..
 

10 More Discussions You Might Find Interesting

1. Programming

Returning Strings from C program to Unix shell script

Hi, Iam calling a C program from a Unix shell script. The (C) program reads encrypted username/password from a text file , decrypts and returns the decrypted string. Is there any way i can return the decrypted string to Unix shell program. My shell script uses the output of the program to... (11 Replies)
Discussion started by: satguyz
11 Replies

2. Shell Programming and Scripting

Returning filename and matching lines

What I'm trying to do is to search through a list of files, and output the filename, followed by the lines that matched the pattern. I'm matching the string "letters.moreletters" in any one of searched files, and the output I'm trying to get is: program_1.txt 10 dsdsd sdsd dsd... (2 Replies)
Discussion started by: smb_uk
2 Replies

3. Programming

Returning Strings from C program to Unix shell script

Hi, I'm having a requirement where I need to call a C program from a shell script and return the value from the C program to shell script. I refered a thread in this forum. But using that command in the code, it is throwing an error clear_text_password=$(get_password) Error: bash:... (24 Replies)
Discussion started by: venkatesh_sasi
24 Replies

4. Shell Programming and Scripting

Shell script: returning the file with the most lines

Hey I am relatively new to Linux and shell scripting, looking for a spot of help with a script I am working on. I am writing a script that counts the number of lines in all the files in a directory, sorts them by line number and then returns ONLY the file with the most lines. Right now I can... (11 Replies)
Discussion started by: Breakology
11 Replies

5. Shell Programming and Scripting

Strings from one file which exactly match to the 1st column of other file and then print lines.

Hi, I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines). ################################# huge_file.txt a a ab b ################################## small_file.txt a 1.5 b 2.5 ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies

6. Shell Programming and Scripting

Delete lines in file containing duplicate strings, keeping longer strings

The question is not as simple as the title... I have a file, it looks like this <string name="string1">RZ-LED</string> <string name="string2">2.0</string> <string name="string2">Version 2.0</string> <string name="string3">BP</string> I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies

7. UNIX for Dummies Questions & Answers

awk display the match and 2 lines after the match is found.

Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file. For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt I tried with grep -A but it's not supported on my system. I tried with awk,... (4 Replies)
Discussion started by: eurouno
4 Replies

8. Shell Programming and Scripting

Print only lines where fields concatenated match strings

Hello everyone, Maybe somebody could help me with an awk script. I have this input (field separator is comma ","): 547894982,M|N|J,U|Q|P,98,101,0,1,1 234900027,M|N|J,U|Q|P,98,101,0,1,1 234900023,M|N|J,U|Q|P,98,54,3,1,1 234900028,M|H|J,S|Q|P,98,101,0,1,1 234900030,M|N|J,U|F|P,98,101,0,1,1... (2 Replies)
Discussion started by: Ophiuchus
2 Replies

9. Shell Programming and Scripting

Script to match strings that sometimes are splitted in 2 lines

Hello to all, I have an hexdump -C format as below: 31 54 47 55 48 4c 52 31 5f 52 31 32 31 31 32 ff 44 00 00 0E 01 32 14 56 42 17 47 48 0f ff ff ff 44 00 00 01 32 14 56 00 23 83 95 2f 42 17 47 48 00 0f ff ff 00 15 00 0a 48 00 01 5a 00 02 17 00 00 2f 00 00 30 00 00 31 00 00 ff 34 ff 44 00... (23 Replies)
Discussion started by: Ophiuchus
23 Replies

10. UNIX for Beginners Questions & Answers

Use strings from nth field from one file to match strings in entire line in another file, awk

I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file. I would like to output the lines of File2 which... (1 Reply)
Discussion started by: jvoot
1 Replies
LAM(1)							    BSD General Commands Manual 						    LAM(1)

NAME
lam -- laminate files SYNOPSIS
lam [-f min.max] [-p min.max] [-s sepstring] [-t c] file ... DESCRIPTION
lam copies the named files side by side onto the standard output. The n-th input lines from the input files are considered fragments of the single long n-th output line into which they are assembled. The name ``-'' means the standard input, and may be repeated. Normally, each option affects only the file after it. If the option letter is capitalized it affects all subsequent files until it appears again uncapitalized. The options are described below. -f min.max Print line fragments according to the format string min.max, where min is the minimum field width and max the maximum field width. If min begins with a zero, zeros will be added to make up the field width, and if it begins with a '-', the fragment will be left-adjusted within the field. -p min.max Like -f, but pad this file's field when end-of-file is reached and other files are still active. -s sepstring Print sepstring before printing line fragments from the next file. This option may appear after the last file. -t c The input line terminator is c instead of a newline. The newline normally appended to each output line is omitted. To print files simultaneously for easy viewing use pr(1). EXAMPLES
The command lam file1 file2 file3 file4 joins 4 files together along each line. To merge the lines from four different files use lam file1 -S " " file2 file3 file4 Every 2 lines of a file may be joined on one line with lam - - < file and a form letter with substitutions keyed by '@' can be done with lam -t @ letter changes SEE ALSO
join(1), pr(1), printf(3) BSD
December 1, 2001 BSD
All times are GMT -4. The time now is 10:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy