How to grep at a given postion


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to grep at a given postion
# 1  
Old 06-12-2007
How to grep at a given postion

All,

I need to grep for a value between particular positions:

Eg:

ACME CORPORATION 3 213.89

I need to look out for the value 3 betwen postions 20 and 26.

Any ideas.

Thanks
KP.
# 2  
Old 06-12-2007
King,
See if works for you:
Code:
grep '^.\{19,25\}3' input_file

# 3  
Old 06-12-2007
Shell,

Thanks
for the reply.

Is there any way I could parameterize the value (ie. the value 3) in the above step.

Thanks
KP
# 4  
Old 06-12-2007
Code:
parameter=5
grep "^.\{19,25\}${parameter}" input_file

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

2. Shell Programming and Scripting

Print column postion

Hi, I am using the below code for printing the column position of a particular string nawk -v srch="DName" -F '\t' '{for(j=1; j<=NF; j++) { if($j==srch) print j } exit }' input_file.txt The above code prints the column position of the input string DName (that is 1) Now the problem is,... (7 Replies)
Discussion started by: sampoorna
7 Replies

3. Shell Programming and Scripting

Ssh = ssh expect and keep everything not change include parameter postion

I have write a script which contains ssh -p 12345 dcplatform@10.125.42.50 ssh 127.0.0.1 -p 5555 "$CMD" ssh root@$GUEST_IP "$CMD" before I use public key, it works well, now I want to change to "expect", BUT I don't want to change above code and "parameter position" I can post a... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

4. UNIX for Dummies Questions & Answers

how to get index/postion of a string?

Hi, I have a string like the following: /db1/data/GLIDER/SYSTEM.dbf need to find the postion where "SYSTEM.dbf" starts, so I tried: LOCATION=/db1/data/GLIDER/SYSTEM.dbf $ expr index $LOCATION SYSTEM expr: syntax error $ expr index "$LOCATION" SYSTEM expr: syntax error ... (5 Replies)
Discussion started by: seafan
5 Replies

5. Shell Programming and Scripting

Need-To remove header/trailor and add-date-on first-postion-plz-help

Hi Friends thanks a lot....for ur replies its worked fine...i have one more question.. if i need to remove trailor (T000000004 ) as shown below file also with header.Plz help thanks Source file: H20100928 D04041201609360677PC790010384I D04041203326357853PC790010645R ... (1 Reply)
Discussion started by: dprakash
1 Replies

6. UNIX for Dummies Questions & Answers

Append line and variable at fixed postion in file in unix

Hi I have a input file ::: 1583904589034853904 1690234849023849023 159823890238409 1690238490238490238490 . . . The output file should have the record 16 appended to the record 15 and a variable should be added at a FIXED POSTION at 55. The records are been processed inside a loop... (3 Replies)
Discussion started by: akashhello
3 Replies

7. Shell Programming and Scripting

replace only 1st word of a line if it comes in the subsequent lines at same postion.

I have a file like this.. Maharastra Mumbai worli Maharastra Mumbai navy maharatra Pune Maharastra Nagpur Karnataka Bangalore Karnataka Mysore Karnataka Mangalore Punjab Amritsar punjab Jalandar my expected outcome should be like this Maharastra Mumbai worli ---------- ... (9 Replies)
Discussion started by: geeko
9 Replies

8. Shell Programming and Scripting

VI editor,column postion

In VI editor ctrl + g is used indicate the line number on which the cursor is placed...similarly is there a way to determine the column number of the cursor position..? (1 Reply)
Discussion started by: vijay_0209
1 Replies

9. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

10. Programming

need info on current curser postion.

Hi All, I have written the below code to know the current curser position. The problem with this code is - it gives me window size properly but whn it comes to current curser position then it gives (0,0) as x,y co-ordinate eventhough my curser is somewhere middle on command line interface. ... (0 Replies)
Discussion started by: swap007
0 Replies
Login or Register to Ask a Question