12-04-2006
Print lines with search string at specific position
Hi Folks,
I have a file with all fields defined by byte position, but any field can be empty so I cannot print lines based on a search of specific columns. I need to print all lines of this file where the string of two characters at byte position 100-101 contains the number 27. Any ideas?
Sample file:
...abc def 987lm
...tia fer g270
... gerta27mlonep
...ferssdfsdff22
I would print the second and third lines.
Thanks
This User Gave Thanks to HealthyGuy For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi, guys. I have one question:
How can I search for a line with certain string in it and then insert a string into this line?
For example:
There is a file called shadow, the contents of it are below:
**************************
...
yuanz:VIRADxMsadfDF/Q:0:0:50:7:::... (9 Replies)
Discussion started by: daikeyang
9 Replies
2. Shell Programming and Scripting
I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (2 Replies)
Discussion started by: manaswinig
2 Replies
3. Shell Programming and Scripting
I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this (1 Reply)
Discussion started by: manaswinig
1 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I am on an AIX Unix box and I am trying to search for a string in between specified lines of code when I vi a file. I can use the '/string' to search for the string through out the file, but can we only search in between specific lines.
I can use the below sed command to search for the... (8 Replies)
Discussion started by: coolavi
8 Replies
5. Shell Programming and Scripting
I have two files abc.dat and sant.dat (Big file 60k rows)
for every line's 1,4 of abc.dat need to seach if this is present on 28,4 of sant.dat every line.
if its present the output needs to go to bde.dat
Example:
contents abc.dat
aaaa
bbbb
cccc
dddd
contents sant.dat
this is... (4 Replies)
Discussion started by: ssantoshss
4 Replies
6. Shell Programming and Scripting
Hi,
I have list of directory paths in a variable and i want to delete those dirs and if dir does not exist then search that string and get the correct path from xml file after that delete the correct directory. i tried to use grep and it prints the entire line from the search.once i get the entire... (7 Replies)
Discussion started by: dragon.1431
7 Replies
7. Shell Programming and Scripting
I woud like to substitue a string on a specific position for specific lines
I've got a file and I would like to change a specific string from "TOCHANGE" to "ABCABCAB"
For every line (except 1,2, 3 and the last one) , I need to check between the 9th and the 16th digits.
For the 3rd line, I... (7 Replies)
Discussion started by: BSF
7 Replies
8. Shell Programming and Scripting
Hi,
Our input xml looks like:
<doc>
<str name="account_id">1111</str>
<str name="prd_id">DHEP155EK</str>
</doc>
- <doc>
<str name="account_id">6666</str>
<str name="prd_id">394531662</str>
</doc>
- <doc>
<str name="account_id">6666</str>
<str... (1 Reply)
Discussion started by: Jassz
1 Replies
9. Shell Programming and Scripting
if the first string matches then print the previous line and current line and also print the following lines if the other string search matches.
Input
------
TranTime 2012 10 12
The Record starts here
Accountnumber: 4632473431274
TxnCode 323
TranID 329473242834
ccsdkcnsdncskd... (7 Replies)
Discussion started by: laknar
7 Replies
10. Shell Programming and Scripting
hi guys,
i want command or script to display the content of file from 2nd position to last but one position of a file
abcdefghdasdasdsd
123,345,678,345,323
434,656,656,656,656
678,878,878,989,545
4565656667,65656
i want to display the same above file without first and... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies
CUT(1) BSD General Commands Manual CUT(1)
NAME
cut -- select portions of each line of a file
SYNOPSIS
cut -b list [-n] [file ...]
cut -c list [file ...]
cut -f list [-d delim] [-s] [file ...]
DESCRIPTION
The cut utility selects portions of each line (as specified by list) from each file and writes them to the standard output. If the file
argument is a single dash ('-') or no file arguments were specified, lines are read from the standard input. The items specified by list can
be in terms of column position or in terms of fields delimited by a special character. Column numbering starts from 1.
list is a comma or whitespace separated set of increasing numbers and/or number ranges. Number ranges consist of a number, a dash (-), and a
second number and select the fields or columns from the first number to the second, inclusive. Numbers or number ranges may be preceded by a
dash, which selects all fields or columns from 1 to the first number. Numbers or number ranges may be followed by a dash, which selects all
fields or columns from the last number to the end of the line. Numbers and number ranges may be repeated, overlapping, and in any order. It
is not an error to select fields or columns not present in the input line.
The options are as follows:
-b list The list specifies byte positions.
-c list The list specifies character positions.
-d string Use the first character of string as the field delimiter character. The default is the <TAB> character.
-f list The list specifies fields, separated by the field delimiter character. The selected fields are output, separated by the field
delimiter character.
-n Do not split multi-byte characters.
-s Suppresses lines with no field delimiter characters. Unless specified, lines with no delimiters are passed through unmodified.
EXIT STATUS
cut exits 0 on success, 1 if an error occurred.
SEE ALSO
paste(1)
STANDARDS
The cut utility conforms to IEEE Std 1003.2-1992 (``POSIX.2'').
BSD
December 21, 2008 BSD