Sponsored Content
Top Forums Shell Programming and Scripting save every line in log file with matched string Post 302300561 by insamniac on Tuesday 24th of March 2009 12:05:27 PM
Old 03-24-2009
Java

Here's a way you could do it in ksh.. not the most efficient way, but worth a shot to see if it eats up your system resources as badly as your method..

Code:
#!/bin/ksh

logfile=/path/to/logfile
namelist=/path/to/namelist
outputdir=/output/dir


cat $namelist | while read name
do

   grep $name $logfile > temp
   if [ $(cat temp | wc -l) -ne 0 ];then 
    
     mkdir  ${outputdir}/$name
     cat temp > ${outputdir}/$name
     cat temp > ${outputdir}/${name}/${name}.txt
       
    fi

done

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Command to display nth line before the string is matched.

All, Is there any way out to display the nth line before the string is matched ??? Eg : If i have a file which has the following contents and if i want to get the 3rd line before the string is matched a b c d e f if i give the input as f and lines before the match as 3 then it should... (5 Replies)
Discussion started by: helper
5 Replies

2. Shell Programming and Scripting

search a string in a line and save it in a variable

Hi I want to read a file line by line and search for a particular string in each line(say for example string containing @ )and save that string into a variable. Can someone suggest me the way to implement it.I am using K- shell Thanks Ishita (5 Replies)
Discussion started by: Ishita
5 Replies

3. Shell Programming and Scripting

Extracting particular string in a file and storing matched string in output file

Hi , I have input file and i want to extract below strings <msisdn xmlns="">0492001956</ msisdn> => numaber inside brackets <resCode>3000</resCode> => 3000 needs to be extracted <resMessage>Request time getBalances_PSM.c(37): d out</resMessage></ns2:getBalancesResponse> => the word... (14 Replies)
Discussion started by: sushmab82
14 Replies

4. UNIX for Advanced & Expert Users

capture data from matched string/line

Hi, I have a query as follows : suppose I am matching a string in a file say "start from here" and I want to pick up 'n' number of lines () from the matched string. Is there any way to do that ? 1) going forward I want to do this for every match for the above string 2) or limit this to... (2 Replies)
Discussion started by: sumoka
2 Replies

5. Shell Programming and Scripting

Match a line in File 1 with Column in File 2 and print whole line in file 2 when matched

Hi Experts, I am very new to scripting and have a prb since few days and it is urgent to solve so much appreciated if u help me. i have 2 files file1.txt 9647810043118 9647810043126 9647810043155 9647810043161 9647810043166 9647810043185 9647810043200 9647810043203 9647810043250... (22 Replies)
Discussion started by: mustafa.abdulsa
22 Replies

6. Shell Programming and Scripting

Help required on joining one line above & below to the pattern matched string line.

Hi Experts, Help needed on joining one line above & below to the pattern matched string line. The input file, required output is mentioned below Input file ABCD DEFG5 42.0.1-63.38.31 KKKK iokl IP Connection Available ABCD DEFG5 42.0.1-63.38.31 ... (7 Replies)
Discussion started by: krao
7 Replies

7. Shell Programming and Scripting

Print only matched string instead of entire line

Hi, I have a file whose lines are something like Tchampionspsq^@~^@^^^A^@^@^@^A^A^Aÿð^@^@^@^@^@^@^@^@^@^@^A^@^@^@^@^?ð^@^@^@^@^@^@^@?ð^@^@^@^@^@^@pppsq^@~^@#@^@^@^@^@^@^Hw^H^@^@^@^K^@^@^@^@xp^At^@^FTtime2psq^@ ~^@^^^A^@^@^@^B^A I need to extract all words matching T*psq from the file. Thing is... (4 Replies)
Discussion started by: shekhar2010us
4 Replies

8. Shell Programming and Scripting

ksh : need to get the 4 th line above and 2 nd below the matched pattern in the log file

I have a log file as given below 012/01/21 10:29:02 (111111) Processing Job '23_369468343464564' 2012/01/21 10:29:02 (111111) Making Job '23_369468343464564.0'... 2012/01/21 10:29:04 (111111) Jobnumber '23_369468343464564' was successful 2012/01/21 10:29:04 ... (12 Replies)
Discussion started by: rpm120
12 Replies

9. UNIX for Dummies Questions & Answers

Commenting a line matched with a specific string in a file

Hi, I would like to comment a line that matched a string "sreenivas" in a file without opening it. Thanks in advance. Regards, Sreenivas (3 Replies)
Discussion started by: raosr020
3 Replies

10. Shell Programming and Scripting

Insert a user input string after matched string in file

i am having file like this #!/bin/bash read -p 'Username: ' uservar match='<color="red" />' text='this is only a test so please be patient <color="red" />' echo "$text" | sed "s/$match/&$uservar\g" so desireble output what i want is if user type MARIA this is only a test so please... (13 Replies)
Discussion started by: tomislav91
13 Replies
RINGS3D(1)						      General Commands Manual							RINGS3D(1)

NAME
rigns3d - produces a file of ring-filling triangles from a PDB file SYNOPSIS
rings3d [-bases] [-protein] [-sugars] < infile.pdb > outfile.r3d rings3d searches through a PDB file looking for residues containing 5- or 6-membered rings, then produces a Raster3D output file of ring- filling triangles. rings3d matches residue types from an internal list of residue and atom names. It will fail to find residues not in its list, and fail to recognize atoms with non-standard names. EXAMPLES
render a DNA molecule with the bases filled in: cat $R3D_LIB/dna.colours dna.pdb | rods -radius 0.05 > temp.1 rings3d -bases < dna.pdb > temp.2 cat temp.1 temp.2 | render -tiff dna.tiff OPTIONS
-bases Fills in purine and pyrimidine rings from A C G T U residues. -protein Fills in sidechain rings of HIS PHE TRP and TYR residues. -sugars [This is the default] Fills in pyranose rings of GAL GLC NAG NGA MAN SIA residues. BUGS
limited residue types The database of residue types should be kept externally, so you don't have to rebuild the program to add a new type. There should be an option to search for ring systems in un-recognized residue types. crinkled planes There should be an option to do a least-squares best plane through supposedly flat rings. Then again, seeing a crease in a "flat" ring may force people to consider whether their planarity restraints are tight enough. SOURCE
anonymous ftp site: ftp.bmsc.washington.edu web URL: http://www.bmsc.washington.edu/raster3d/raster3d.html contact: Ethan A Merritt Dept of Biological Structure Box 357742 University of Washington, Seattle WA 98195 merritt@u.washington.edu SEE ALSO
Raster3D(l) AUTHORS
Ethan A Merritt. This manual page was written by Nelson A. de Oliveira <naoliv@gmail.com>, for the Debian project (but may be used by others). Raster3D RINGS3D(1)
All times are GMT -4. The time now is 09:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy