How to filer a line in special condition?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to filer a line in special condition?
# 1  
Old 02-10-2009
How to filer a line in special condition?

Hi,
I hava log file which has the following output :
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_1_20090210.zip
Created RELEASE in dist/filename_release_1_3_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_4_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip

for special sorting purpuse I want each of the line to be filtered like

/filename_1_0
/filename_1_1
/filename_1_3
/filename_1_0
/filename_1_0
/filename_1_4
/filename_1_0
/filename_1_0
/filename_1_0
/filename_1_0

i.e the "release" word to be filtered out and version is to be attached woth the file name. As I am new to the filtering part of UNIX could not make out what to use any sed/awk/perl ..Please help. Waiting for an aspiring response. Thank you.
# 2  
Old 02-10-2009
try sed commnad like this
sed -e 's/.*dist//' < filename
# 3  
Old 02-10-2009
Quote:
Originally Posted by scorpio
try sed commnad like this
sed -e 's/.*dist//' < filename

Its ok...but how to remove on of the "release" word and add the version and remove the time stamp to flitered output could u plz gelp on this more?
# 4  
Old 02-10-2009
sorry ..

This is the complete command

sed -e 's/.*dist//' < testfile.txt | cut -d "_" -f1-4
# 5  
Old 02-10-2009
Quote:
Originally Posted by scorpio
sorry ..

This is the complete command

sed -e 's/.*dist//' < testfile.txt | cut -d "_" -f1-4
Excellent sir ...but still it is not removing the "release" word else is ok. Waiting for an aspiring response from your side.
# 6  
Old 02-10-2009
Bhaskar,

Try the below command.

Code:
cut -d '/' -f2 < filename | sed -e 's/release_//g' -e 's/.zip//g' | cut -d '_' -f1-3

HTH, Smilie

Regards,

Praveen
# 7  
Old 02-10-2009
HI Praveen,
Superb!! Its working fine. Thanks for this nice help.
Regards,
Bhaskar
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If condition fails for special charecter

I have a sample server name listed in variable as below: var="server-13" I need to check if the 7th character on $var is number 1 whichenv=`echo "$var"| head -c 7 | tail -c 1` if ]; then echo "9 found" else echo "9 Not Found" fi Output: This works... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. UNIX for Beginners Questions & Answers

How To Retreive Files With a Special Condition?

Everyday I have to get a list of files in a directory with a special condition and feed this list to a for loop to be processed. Since I do not use Unix all the time, it is tricky for me to get that list of files. So, the question is whether there are commands that will give me the file names... (12 Replies)
Discussion started by: april
12 Replies

3. Shell Programming and Scripting

Find line then evaluate text on next line, print when condition is met

Hello, I am looking for a specific situation in a text file. The conditions are, > <CompoundName> InChI=1S/C5H12NO2/c1-5(2)4-8-6(3)7/h5H,4H2,1-3H3/q+1 I am looking for cases where the line "> <CompoundName>" is followed by a line that contains the string "InChI=" without regard to... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

4. Shell Programming and Scripting

Append Next line with current Line bassed on condition

Hi, I have an XML file and I am tring to extract some data form it, after lot of data cleaning process, I ended up with an issue, and need your urgent support. my current input data in below format: <Node>xxxxxx <Node>yyyyy</Node> <Node>zzzzzz <Node>12345</node> I need... (9 Replies)
Discussion started by: rramkrishnas
9 Replies

5. Shell Programming and Scripting

Columns to Rows - Transpose - Special Condition

Hi Friends, Hope all is well. I have an input file like this a gene1 10 b gene1 2 c gene2 20 c gene3 10 d gene4 5 e gene5 6 Steps to reach output. 1. Print unique values of column1 as column of the matrix, which will be a b c (5 Replies)
Discussion started by: jacobs.smith
5 Replies

6. Shell Programming and Scripting

If condition matching with special chars

Hi, I have file #cat drivers.txt fcs0 fcs1 vscsi1 vscsi2 In this i need to check the availabality of "fcs" or "vscsi" alone not vscsi0,fcs1 I tried with "if condition" but it is not working. cat drivers.txt| while read ADAP do echo "Checking for $ADAP" if ;then echo "FC... (9 Replies)
Discussion started by: ksgnathan
9 Replies

7. Shell Programming and Scripting

Print every 5 lines with special condition

Hi Friends, I have an input file like this chr1 100 200 chr1 200 300 chr1 300 400 chr1 400 500 chr1 500 600 chr1 600 700 chr1 700 800 chr1 800 900 chr1 900 920 chr1 940 960 I would like to get the first line's second column and the fifth line's 3rd column as one single line. This... (13 Replies)
Discussion started by: jacobs.smith
13 Replies

8. Emergency UNIX and Linux Support

Find a line using a condition and replace a string in that line

Hello, I have a 100 line code. I have given a sample of it below: ABC*654654*1*54.54*21.2*87*1*654654654654 CCC*FS*FS*SFD*DSF GGG*FGH*CGB*FBDFG*FGDG ABC*654654*1*57.84*45.4*88*2*6546546545 CCC*WSF*SG*FGH*GHJ ADA*AF*SFG*DFGH*FGH*FGTH I need to select the line starting with "ABC" its... (3 Replies)
Discussion started by: nithins007
3 Replies

9. UNIX for Dummies Questions & Answers

Strings with Special chars in IF condition

I was trying to run a code to check if a fax number is empty or not. for that, I've written the following code which is throwing an error. #!/bin/ksh fax= "999-999-9999" if ; then fax_no="000-000-0000" else fax_no=$fax fi echo $fax_no And I get the... (7 Replies)
Discussion started by: hooaamai
7 Replies

10. Shell Programming and Scripting

How to insert a character in line in Special condition?

Hi, I have a log file generated by a tool which has the following look : /tmp/releases/directory/datefilename1_release_date.zip /tmp/releases/directory/datefilename2_release_date.zip /tmp/releases/directory/datefilename3_release_date.zip... (8 Replies)
Discussion started by: bhaskar_m
8 Replies
Login or Register to Ask a Question