Held req: Awk - remove non-alpha line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Held req: Awk - remove non-alpha line
# 1  
Old 09-26-2010
Held req: Awk - remove non-alpha line

Hi All,

I have a file containg lines along the likes of:

Code:
18:02:00 JOB02084722
18:09:00 2010120942
18:12:04 JOB02084723
18:34:16 20100709

etc.

What I want to do is remove the entire line when field 2 starts with a number so I'm left with:

Code:
18:02:00 JOB02084722
18:12:04 JOB02084723

I can't use awk to remove all numberics because they appear validly in some of the jobnames. I've had a look through a lot of awk and sed stuff but can't seem to find it. Any help much appreciated.

G

Last edited by Scott; 09-26-2010 at 07:48 AM..
# 2  
Old 09-26-2010
Something like:

Code:
awk '$2 !~ /^[0-9]/'

# 3  
Old 09-26-2010
Code:
$ ruby -ane 'print if $F[1]!~/^\d/' file
18:02:00 JOB02084722
18:12:04 JOB02084723

# 4  
Old 09-26-2010
Thanks for that it works fine but I forgot to add that sometimes the file contains a blank record in field 2.

Could you help with the awk for removing ALL non-aplha characters?
# 5  
Old 09-26-2010
Code:
sed '/ [0-9]/d' infile

# 6  
Old 09-26-2010
Your question isn't clear.

Quote:
Originally Posted by Grueben
Thanks for that it works fine but I forgot to add that sometimes the file contains a blank record in field 2.

Could you help with the awk for removing ALL non-aplha characters?
Define a "blank record". Does that mean "no record"? "remove all non-alpha characters" from where?

Quote:
Originally Posted by rdcwayx
Code:
sed '/ [0-9]/d' infile

This wouldn't work if there is no second record, if the second record has any numbers or if there are more than two records.
# 7  
Old 09-26-2010
Cheers Scottn. The file looks like:
Code:
18:02:00 JOB02084722
18:06:00
18:09:00 2010120942
18:12:04 JOB02084723
18:34:16 20100709

Basically all I want from it are the lines where the 2nd field starts with 'JOB'. All other lines can be deleted. Appreciate your help

Last edited by Franklin52; 09-27-2010 at 03:28 AM.. Reason: Please use code tags!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to remove line if field has symbols in it

Trying to use awk to remove a line only if $1 contains either ; or :. Thje awk below runs but no lines are removed. Thank you :). awk awk '$1 !~ /;/ || $1 !~ /:/ { print }' file file AARS2;TMEM151B 1 AASS 2 ABAT 3 ABCA1 3 ABCA10 1 ABCA12 2 ABCA13 1 ABCA13:AX746840 2 ABCA2 5 (5 Replies)
Discussion started by: cmccabe
5 Replies

2. Shell Programming and Scripting

Remove line based on condition in awk

In the following tab-delimited input, I am checking $7 for the keyword intronic. If that keyword is found then $2 is split by the . in each line and if the string after the digits or the +/- is >10, then that line is deleted. This will always be the case for intronic. If $7 is exonic then nothing... (10 Replies)
Discussion started by: cmccabe
10 Replies

3. Shell Programming and Scripting

awk remove line

I would like to remove lines with certain pattern but only Estimate: and Realised: in USD and Date: shall be output. The order of the currency are mixed. Output I failed on awk with sub, gensub and was not able to remove the multiple entry on the * Date: (2 Replies)
Discussion started by: sdf
2 Replies

4. Shell Programming and Scripting

awk to search for pattern and remove line

I am an awk beginner and need help figuring out how to search for a number in the first column and if it (or anything greater) exists, remove those lines. AM11400012012 2.26 2.12 1.98 2.52 3.53 3.01 3.62 5.00 3.65 7.95 0.79 3.88 0.00 AM11400012013 3.39 2.29 ... (1 Reply)
Discussion started by: ncwxpanther
1 Replies

5. Shell Programming and Scripting

awk remove line feed

Hi, I've this file: 1, 2, 3, 4, 5, 6, I need to remove the line feed LF every 3 row. 1,2,3, 4,5,6, Thanks in advance, Alfredo (5 Replies)
Discussion started by: alfreale
5 Replies

6. Shell Programming and Scripting

awk : Remove column1 and last column in a line

Hi All, How to remove col1 and last column in a line. Please suggest some awk stuffs. Input col1 col2 col3 col4 col1 col2 col3 col4 col5 col1 col2 col3 col4 col1 col2 col3 Output Processing col2 col3 ... Processing col2 col3 col4 ... Processing col2 col3 ... Processing... (5 Replies)
Discussion started by: k_manimuthu
5 Replies

7. Shell Programming and Scripting

AWK: Remove spaces before processing each line?

Hi, all I have a file containing the following data: name: PRODUCT_1 date: 2010-01-07 really_long_name: PRODUCT_ABCDEFG I want to get the date (it is "2010-01-07" here), I could use the following code to do that: awk... (6 Replies)
Discussion started by: kevintse
6 Replies

8. UNIX for Dummies Questions & Answers

Req 1-liner for Awk, et al to find str position

Hi, I'm trying to find the position of a series of numbers within a large text file. The numbers are separated by spaces. This works fine: type Huge_File.txt | gawk "{print index($0,"255")}" But this does not: type Huge_File.txt | gawk "{print index($0,"188 028 239 160 016 190 137... (4 Replies)
Discussion started by: Lemming42
4 Replies

9. Shell Programming and Scripting

awk script to remove duplicate rows in line

i have the long file more than one ns and www and mx in the line like . i need the first ns record and first www and first mx from line . the records are seperated with tthe ; i am try ing in awk scripting not getiing the solution. ... (4 Replies)
Discussion started by: kiranmosarla
4 Replies

10. Shell Programming and Scripting

(Req)Shell script req

HI All Im new to shell scripting...kindly plz help me... I need a shell script for: We have to take export of all db's on daily basis from all svr's and keep these export backups on diffrent server. Plz help. Regards Gaurav (5 Replies)
Discussion started by: ergauravtaneja
5 Replies
Login or Register to Ask a Question