grab the line using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grab the line using awk
# 1  
Old 10-10-2007
grab the line using awk

suppose u have a file
AAAAAKKSKSKMSKMSKBNNSHNKSNJNMSYNMSBH
This is exactly wht the input is like
Question is i want to list wht is on the line 5 tht will be A
but Remember u want to extract in between say from 100 to 300
i tried using
awk 'BEGIN {FS=""} {print$100,$300}' file
but it will print only wht is the line on 100 and 300 so the question is how to grep or extract the line between 100 and 300??
thanks
# 2  
Old 10-10-2007
Er, when you say lines, does that mean that it is actually seperated by '\n'? Or is this all on one line? If it is all on one line, use this:
Code:
awk '{print substr($0,100,200)}' file

For seperate lines, use sed:
Code:
sed -n '100,300p' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grab text after pattern on the same line

data: 8iW5iPACIb5fafafEU24f3EOOjpakx6VwxBX+NafafxJMWX8iW5iPACIb5fafafEU24f3EOOjpakx6VwxBX+NafafxJMWX8iW5i PACIb5fafafEU24f3EOOjpakx6VwxBX+NafafxJMWX8iW5iPACIb5fafafEU24f3EOOjpakx6VwxBX+ 8nwR15UzfeZafaf2bGr8akx6VwxBX+NafafxJMWX8iW5iPACIb5fafafEU24f3EOOjp lVpOoMLXJ ... (19 Replies)
Discussion started by: SkySmart
19 Replies

2. Shell Programming and Scripting

awk to grab data in range then search for pattern

im using the following code to grab data, but after the data in the range im specifying has been grabbed, i want to count how many instances of a particular pattern is found? awk 'BEGIN{count=0} /parmlib.*RSP/,/seqfiles.*SSD/ {print; count++ } /103 error in ata file/ END { print count }'... (3 Replies)
Discussion started by: SkySmart
3 Replies

3. Shell Programming and Scripting

Grab fields without awk

so i want to avoid external calls in my script, so im trying to do the following: AllMyLogs="hello---nallo---wello---bollo tello---zello---jello---kello" OLDIFS="$IFS\\\n" IFS="---" set -- ${AllMyLogs} IFS="$OLDIFS" I want it to work in a way that, when i type this: echo $2 I... (1 Reply)
Discussion started by: SkySmart
1 Replies

4. Shell Programming and Scripting

Grab line regardless of if it ends with tabs or spaces

so i have a data file that has various lines which may or may not end with spaces or tabs. data.file: , \t \t {sample} <spaces> <spaaces> several more spaces.... {"resemble"}, <nospaces> Command i'm using: sed -n 8p data.file | egrep "\],$|\],\ $" or egrep "\],$|\],\ $"... (1 Reply)
Discussion started by: SkySmart
1 Replies

5. Shell Programming and Scripting

awk to grab the most found lines

awk 'NR>=5034&&/Max/{++c}c==3{o=$0 RS $0 RS $0; print o; c=0}' logfile i would like to modify the above awk command to instead show lines that are the most frequent: for instance, given a log file containing: Warning MaxClient is having issues - please MaxClients java error...yams... (4 Replies)
Discussion started by: SkySmart
4 Replies

6. Shell Programming and Scripting

grep grab 19 letters from now or a full line

Hi, I have a file like this >hg19_chr1_123_456_+ asndbansbdahsjdbfsjhfghjdsghjdghjdjhdghjjdkhfsdkjfhdsjkdkjghkjdhgfjkhjfkf hasjgdhjsgfhjdsgfdsgfjhdgjhdjhdhjdfhjdfjgfdfbdghjbfjksdhfjsfdghjgdhjgfdjhgd jhgdfj >hg19_chr1_123_456_-... (5 Replies)
Discussion started by: jacobs.smith
5 Replies

7. Shell Programming and Scripting

Grab first or second line after a search string

In a shell script, I need to grab the first or second line after a search string in a file. For example: File.out: Random Info Manufacturer: XYZPDQ System Info Manufacturer: Hewlett-Packard Product Name: ProLiant I search for the word FILE, I want to be able to grab the line... (1 Reply)
Discussion started by: jwk1230
1 Replies

8. Shell Programming and Scripting

How to grab the value of field before the line reached

Hi. I have a qury whihc I hope someone could clarify. I have a file:- Num Measure 108 0.05 12 0.45 13 0.2 19 0.5 I wanted to grep the value of 19 from Column Num which will then take the minimum value of measure (not including 19's measure value).... (3 Replies)
Discussion started by: ahjiefreak
3 Replies

9. Shell Programming and Scripting

grab next consecutive line or lines

Hello i'm writting a krn shell that will find the letter F and I would like to grab everything from F till 0:00. Is there a sed or awk command that i could use. Thank you. File is looks like this. 11/12 xxx xxxx xxx F xxxx xxxx some info entered here some info entered here xxxx... (1 Reply)
Discussion started by: wisher115
1 Replies

10. Shell Programming and Scripting

find 2 line numbers, grab text in between

hi, i have a large text file that I just want to extract the important information from. It will be a random number of lines but between two specific line numbers/markers. I was thinking I could get the line number for the first marker: Tablespace Percent Total Free Then get the line... (11 Replies)
Discussion started by: Da_Duck
11 Replies
Login or Register to Ask a Question