awk regardless positions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk regardless positions
# 1  
Old 09-20-2011
awk regardless positions

PHP Code:
brw-------    1 oracle   dba          4921 Apr 05 11:45 dprod_0000018
brw
-------    1 oracle   dba          4926 Apr 05 11:45 dprod_0000019
brw
-------    1 oracle   dba          4393 Feb 02 2011  dprod_000002
brw
-------    1 oracle   dba          4927 Apr 05 11:45 dprod_0000020
brw
-------    1 oracle   dba          4929 Apr 05 11:45 dprod_0000021
brw
-------    1 oracle   dba          4930 Apr 05 11:46 dprod_0000022
brw
-------    1 oracle   dba          4935 Apr 05 11:46 dprod_0000023 
I need to grep the file names (dprod_xxxxx), but
PHP Code:
ls -al |grep prod awk '{ print $10 }' 
ls -al |grep prod awk '{ print $9 }' 
don't let me get all of them because of positions due to the different date and time format (i.e. Feb 02 2011 and Apr 05 11:46)

Please advise how to get all of the file names (dprod_xxxxx).

Thank you
# 2  
Old 09-20-2011
$10 prints the filename for me for every file.

What's wrong with ls -al dprod_*?

For AWK, even though I had no problems, for filenames without spaces, you can use $NF instead of $9, $10, etc.
This User Gave Thanks to Scott For This Post:
# 3  
Old 09-20-2011
Great! $NF works fine.
# 4  
Old 09-20-2011
I saw your another post. I think you just need ls dprod* instead of all the piped commands. -l in ls command will give the long listing. Give it a try!

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 5  
Old 09-20-2011
Of course! The point I was trying to make (ls) for just the filenames. Doh! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find flanking positions

I have a positions file with markers in col1 and position defined by chromosome and location in col2 and col3 m1 ch1 1 m2 ch1 5 m3 ch1 50 m4 ch2 567 m5 ch2 4567 m6 ch2 7766 m7 ch2 554433 m8 ch3 76 m9 ch3 456 m10 ch3 2315 Given a set of query marker, I would like to know what are the... (1 Reply)
Discussion started by: jianp83
1 Replies

2. Shell Programming and Scripting

Join based on positions

I have two text files as shown below cat file1.txt Id leng sal mon 25671 34343 56565 5565 44888 56565 45554 6868 23343 23423 26226 6224 77765 88688 87464 6848 66776 23343 63463 4534 cat file2.txt Id number 25671 34343 76767 34234 23343 23423 66776 23343 (4 Replies)
Discussion started by: halfafringe
4 Replies

3. UNIX for Dummies Questions & Answers

Replace alphabets from certain positions

Hi all, I have column 2 full of values like HIVE4A-56 and HIVE4-56. I want to convert all values like HIVE4A-56 to HIVE4-56. So basically I want to delete all single alphabets before the '-' which is always preceded by a number. Values already in the desired format should remain unchanged... (4 Replies)
Discussion started by: ames1983
4 Replies

4. Shell Programming and Scripting

Modifying a sequence using positions!

Hi.. i have two files one with positions information and another is sequence information. Now i need to read the positions and take the snps at the positions and replace that position base with the snp information in the sequence and write it in the snp information file.. for example Snp file... (6 Replies)
Discussion started by: empyrean
6 Replies

5. Shell Programming and Scripting

Manipulate fields with AWK whose positions are changable

Hello Friends, I've been working with lots of different CDR-EDR files, before testing i need to manipulate my test files rather than requesting new files(to prepare them for next tests) which are different kind of CDRs,EDRs. In order to do this i might have to change more than a field in a... (3 Replies)
Discussion started by: EAGL€
3 Replies

6. Shell Programming and Scripting

sed using data in two different positions

Hi, I cannot figure out how to input a greater than command for a item of data that may be in two different positions. my input file looks like this. isup,isupmap,2011,05,10 isup,isupmap,2011,05,11 isup,isupmap,2011,05,12 pcap,2011,05,10 pcap,2011,05,11 pcap,2011,05,12 You will see... (2 Replies)
Discussion started by: imarcs
2 Replies

7. Shell Programming and Scripting

awk script replace positions if certain positions equal prescribed value

I am attempting to replace positions 44-46 with YYY if positions 48-50 = XXX. awk -F "" '{if (substr($0,48,3)=="XXX") $44="YYY"}1' OFS="" $filename > $tempfile But this is not working, 44-46 is still spaces in my tempfile instead of YYY. Any suggestions would be greatly appreciated. (9 Replies)
Discussion started by: halplessProblem
9 Replies

8. Shell Programming and Scripting

awk modifying entries on 2 lines at 2 positions

Hi this script adds text in the correct place on one line only, in a script. awk 'BEGIN{ printf "Enter residue and chain information: " getline var < "-" split(var,a) } /-s rec:/{$7=a; } {print}' FLXDOCK but I need the same info added at position 7 on line 34 and... (1 Reply)
Discussion started by: gav2251
1 Replies

9. Shell Programming and Scripting

selective positions from a datafile

Hi dear friends, Im writing a shell script which has to select the strings based on the position. but the problem is there is no field seperator. Normally a datafile contains 2000 records (lines) and each line is of size 500 charecters. I want to select the fields from all the lines which... (10 Replies)
Discussion started by: ganapati
10 Replies
Login or Register to Ask a Question