sed - How to select the nth line of a file from a variable in bash? -


possible duplicate: bash tool nth line file

i need select nth line file, line defined variable pbs_arrayid

the accept solution in question (link above) is:

sed 'numq;d' job_params 

i'm trying adapt variable (actually try lots of stuff, 1 makes more sense):

sed "${pbs_arrayid}q;d" job_params 

but following error:

sed: -e expression #1, char 2: invalid usage of line address 0 

what doing wrong?

here awk example.

lets have file:

cat file 1 one 2 two 3 three 4 four 5 five 6 six 7 seven 8 eight 9 nine 

then have theses variable:
var="four"
number=2

then awk gives:

awk '$0~v {f=nr} f && f+n==nr' v="$var" n="$number" file 6 six 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -