Identifying a string from a set of files and printing to a new file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Identifying a string from a set of files and printing to a new file
# 1  
Old 05-14-2010
Bug Identifying a string from a set of files and printing to a new file

Dear All,
I'm an amateur to writing scripts and need to do the following

Need to read all files with a .log extension in a directory and identify the value for username i.e. all files have something like username = John. Once this is read, I need to print this value to a new file. The new file should have the information of the username and the file name that the value was read from.
Any help would be appreciated.

Kelly
# 2  
Old 05-14-2010
Code:
nawk -F= '$1=="username" {print FILENAME, $0}' *.log

# 3  
Old 05-14-2010
Dear vgersh99,
Truly appreciate your super fast response.
I will give this a try and let you know if I run into any issues.

Regards
Kelly
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Identifying .log files

Hi. Is there a way to: 1) produce a listing of .log files 2) older than 5 years of age 3) that includes the full path and filename together with one file per line Any help producing such a script would be very helpful. Thanks. (7 Replies)
Discussion started by: buechler66
7 Replies

2. Shell Programming and Scripting

Help in printing n number of lines if a search string matches in a file

Hi I have below script which is used to grep specific errors and if error string matches send an email alert. Script is working fine , however , i wish to print next 10 lines of the string match to get the details of error in the email alert Current code:- #!/bin/bash tail -Fn0 --retry... (2 Replies)
Discussion started by: neha0785
2 Replies

3. Shell Programming and Scripting

Identifying suffixes in a file and printing them out

Hello, I am interested in finding and identifying suffixes for Indian names through an awk script or a perl program. Suffixes normally are found at the end of a word as is shown in the sample given below. What I need is a perl script which will identify suffixes of a defined lenght to be given in... (4 Replies)
Discussion started by: gimley
4 Replies

4. Shell Programming and Scripting

Identifying entries based on 2 fields in a string.

Hi Guys, I’m struggling to use two fields to do a duplicate/ unique by output. I want to look IP addresses assigned to more than one account during a given period in the logs. So duplicate IP and account > 1 then print all the logs for that IP. I have been Using AWK (just as its installed... (3 Replies)
Discussion started by: wabbit02
3 Replies

5. Shell Programming and Scripting

Finding compound words from a set of files from another set of files

Hi All, I am completely stuck here. I have a set of files (with names A.txt, B.txt until L.txt) which contain words like these: computer random access memory computer networking mouse terminal windows All the files from A.txt to L.txt have the same format i.e. complete words in... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

6. Shell Programming and Scripting

Help identifying the first word in a string

Hi all, I'd like to know how to identify the first word in a string (in bash) for e.g. echo "enter your name" read name (user enters 'Joe Bloggs' for e.g.) echo "hello $name" (output says "hello Joe") Thanks for any help (5 Replies)
Discussion started by: kazazza
5 Replies

7. Shell Programming and Scripting

Searching String from set of similar File pattern from the Dir

Guys, Here is the script that searches string from the set of similar files from the log directory, All the file patterns are defined as input file, from where the script should map to those files in the LOG_DIR and should start searching the strings from all those similar files. ... (1 Reply)
Discussion started by: raghunsi
1 Replies

8. UNIX for Dummies Questions & Answers

identifying core dump files.

I have come into a business environtment problem and had been 10+ years since the last time I did any unix admin work. A long time ago some mainframe person created an app that talked to a mainframe on UNIX and wrote a c program with "core" in the file name to indicate that the file was the... (2 Replies)
Discussion started by: pcooke2002
2 Replies

9. Shell Programming and Scripting

printing lines to a file from a particular string

Hi, A very Good Evening to All, I am writing a script for my application. I have a file with 1000 lines. Among that 1000 lines i am searching for a particular string. And from that string i need to pull all the data in to a seperate file. For example the contents of my file is as below. ... (4 Replies)
Discussion started by: intiraju
4 Replies

10. Shell Programming and Scripting

Identifying New and Modified Files/Directories

Hi. Our shop is migrating to a new UNIX server and our hope is to do a full migration of all files to the new server weeks in advance of the final migration. As a result we want to identify files on our SOLARIS 8 UNIX server that have changed or that were created after a specific date & time... (2 Replies)
Discussion started by: buechler66
2 Replies
Login or Register to Ask a Question