Sponsored Content
Top Forums Shell Programming and Scripting how to find the shortest line which containing a key string? Post 302603620 by sunnydanniel on Thursday 1st of March 2012 01:41:14 PM
Old 03-01-2012
how to find the shortest line which containing a key string?

hi all,

suppose a key string: M0271857

and to find all lines containing this key string in a text file

which returns multiple lines

but i only want the shortest one

is there a way to do that?

thanks so much!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help for shell script of finding shortest substring from given string by user

please give me proper solution for finding a shortest substring from given string if string itself and first char and last char of that substr are also given by user if S="dpoaoqooroo" and FC="o" and LC="o",then shortest substr is "oo" and rest of the string is "dpoaoqroo" i have code but it is... (1 Reply)
Discussion started by: pankajd
1 Replies

2. Shell Programming and Scripting

To find largest and shortest word in eld

I got a file called Album in that there is list of songs i want to find the Longest and shortest song name in field 2 ie ($2).... Please help me with "awk" (2 Replies)
Discussion started by: Markwaugh
2 Replies

3. Shell Programming and Scripting

find the string in a line

Hello I have a abc.txt file which semicolon delimited. I need to read the first line of the abc.txt file where i need to extract specific string which at specific location. i.e first line of the abc.txt file is as below abc;123;xyz;345;678 my requirement is i need to get the 678. I was... (7 Replies)
Discussion started by: dsdev_123
7 Replies

4. Programming

Find a line containing a string.

Hello. I have a large file that contains a lot of gibberish and also a lot of http addresses. How can i read the file, take out the http addresses, and write each one of them on one line each into another file? It looks something like this. ... (1 Reply)
Discussion started by: cbreiny
1 Replies

5. Shell Programming and Scripting

Find line containing string in a file.

Hello. I have a large file that contains a lot of gibberish and also a lot of http addresses. How can i read the file, take out the http addresses, and write each one of them on one line each into another file? It looks something like this. ... (7 Replies)
Discussion started by: cbreiny
7 Replies

6. Shell Programming and Scripting

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... (6 Replies)
Discussion started by: nithins007
6 Replies

7. 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

8. UNIX for Advanced & Expert Users

How to find a string in a line in UNIX file and delete that line and previous 3 lines ?

Hi , i have a file with data as below.This is same file. But actual file contains to many rows. i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ? Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies

9. Homework & Coursework Questions

Need help how to search for shortest line from a file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have to write a program that have to read every standard input then print out the line number and the content of... (10 Replies)
Discussion started by: scopiop
10 Replies

10. Shell Programming and Scripting

Find a string and its position in a line from another string

Hello guys, would you please help me with this? this is the line inside a file: first line Something Today YYDDPPSVXIPYYY0XXXOFFS00000000000? I'd like to find the position of string XXX from string PYYY In the example above XXX starts from 6th position from PYYY desired... (4 Replies)
Discussion started by: netrom
4 Replies
GRIB_SET(1)							   User Commands						       GRIB_SET(1)

NAME
grib_set - Sets key/value pairs in gribs. DESCRIPTION
Sets key/value pairs in the input grib file and writes each message to the output_grib_file. It fails when an error occurs (e.g. key not found). USAGE
grib_set [options] grib_file grib_file ... output_grib_file OPTIONS
-s key[:{s/d/l}]=value,key[:{s/d/l}]=value,... Key/values to set. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be defined. By default the native type is set. -r Repack data. Sometimes after setting some keys involving properties of the packing algorithm a repacking of data is needed. This repacking is performed setting this -r option. -d value Set all the data values to "value". -p key[:{s/d/l}],key[:{s/d/l}],... Declaration of keys to print. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be requested. Default type is string. -P key[:{s/d/l}],key[:{s/d/l}],... As -p adding the declared keys to the default list. -w key[:{s/d/l}]=value,key[:{s/d/l}]=value,... Where clause. Set is only executed for grib messages matching all the key/value constraints. If a grib message does not match the constraints it is copied unchanged to the output_grib_file. This behaviour can be changed setting the option -S. For each key a string (key:s) or a double (key:d) or a long (key:l) type can be defined. Default type is string. -7 Does not fail when the message has wrong length -S Strict. Only grib messages matching all the constraints are copied to the output file -V Version. -M Multi-grib support off. Turn off support for multiple fields in single grib message -g Copy GTS header. -G GRIBEX compatibility mode. -f Force. Force the execution not to fail on error. -v Verbose. AUTHOR
This manpage has been autogenerated by Enrico Zini <enrico@debian.org>from the command line help of grib_set. grib_set April 2009 GRIB_SET(1)
All times are GMT -4. The time now is 04:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy