Search and print a certain number in a file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search and print a certain number in a file
# 1  
Old 09-16-2011
Search and print a certain number in a file


I have a file that contains strings and numbers. I want to search for a particular string and then print out the numbers next to this string.

For example the file looks like in the file I want to search for the line

AFUE      0.
AOXI      0.
VFUE     600.
VOXI     1573.241
TFUE    300.
TOXI    1666.874 !1500.
TMAX   2400.
GRID  .00
GRID  .05
GRID  .10

I want to search for VOXI and then print out 1573.241 in a file.

Many thanks.
# 2  
Old 09-16-2011
See if this can help you:
sed -n '/VOXI/s/VOXI//p' File

This User Gave Thanks to Shell_Life For This Post:
# 3  
Old 09-16-2011

That works! Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Search for specific key in a file and print it

Hi All, I have a file abc.txt Database unique name: NEPAL Database name: NEPAL Services: NEPAL_COB,NEPAL_PROD output i need is it should search "Services" and it that search "COB" word so output i need is like NEPAL_COB (3 Replies)
Discussion started by: amar1208
3 Replies

2. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies

3. UNIX for Beginners Questions & Answers

Search directory for string and print file name

Good Evening Folks - I have a need to search a specific directory and ALL sub-directories for the following string: Data Load UpdatedIf this string is found, I need to print content from the line directory above it between symbols, as well as the file name where it is found. Here is a... (1 Reply)
Discussion started by: SIMMS7400
1 Replies

4. UNIX for Dummies Questions & Answers

Search file and print everything except multiple search terms

I'm trying to find a way to search a range of similar words in a file. I tried using sed but can't get it right:sed 's/\(ca01\)*//'It only removes "ca01" but leaves the rest of the word. I still want the rest of the information on the lines just not these specific words listed below. Any... (3 Replies)
Discussion started by: seekryts15
3 Replies

5. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

6. Shell Programming and Scripting

Search from one file and print the next line

Hi, I have a file that contain more than a 1000 entries like this in one file P400000278 P400000446 P400000659 P400000789 I want to search in file that looks like this >P400000278 Adenosine 3'-phospho 5'-phosphosulfate transporter MVNPWKDYVKLSTVLMGSHGLTKGSLAFLNYPAQIMFKSAKVLPVMVMGAFVPGL... (5 Replies)
Discussion started by: Feeqa
5 Replies

7. Shell Programming and Scripting

Print columns in a file by number list in another file

This should follow with my last post but I think it's better to start a new one. Now I have a list of numbers stored in pos.txt: 2 6 7 . . . n . . . And I need to extract (2n-1, 2n) columns from matrix.txt: ind1 A B C D E F G H I J K L M N O P Q R ... ind2 B C D E F G H... (3 Replies)
Discussion started by: Zoho
3 Replies

8. Shell Programming and Scripting

print or display certain number of file

Hi, I am sure this is possible in awk or sed or a combination of the two. Can someone help me determine the best way to display or print certain section of a file, ie only certain number of lines. Example: File1 1 has 20 lines. I need to be able to print from line 5 to line 10 of this file.... (2 Replies)
Discussion started by: jerardfjay
2 Replies

9. Shell Programming and Scripting

search for the contents in many file and print that file using shell script

hello have a file1 H87I Y788O T347U J23U and file2 J23U U887Y I99U T556U file3 I99O J99T F557J file4 N99I T666U R55Y file5 H87I T347U file6 H77U R556Y E44T file7 Y788O K98U H8I May be using script we can use file1 to search for all the files and have the output H87I file5... (3 Replies)
Discussion started by: cdfd123
3 Replies

10. Shell Programming and Scripting

how to search string and number in one file and check in the other file

Hi, Can anyone help in the below problem. file1 has the below contents fileset 999 primary-ilist inode 37020 has invalid dotdot (426094) -> Not exist fileset 999 primary-ilist inode 115016 dup block ->... (9 Replies)
Discussion started by: knshree
9 Replies
Login or Register to Ask a Question