linux - Get certain bunch of rows -



linux - Get certain bunch of rows -

i need help in following: have kind of file, named file-1

1 ++++++^^++++ ++++++++++++ +++++++++^^^ ^^++++++++++ 2 ++++++++++++ ^^^+++++^^^^ ^^^^^^^+++++ +++++^^^++^+

now, print out part in starting number same in file, named file-2. allow file-2 contains 1 value, need output:

1 ++++++^^++++ ++++++++++++ +++++++++^^^ ^^++++++++++

can suggest me something?

$ awk -v rs='' 'nr==fnr{split($0, a, /\n/); next}; $1 in a' file-{2,1} 1 ++++++^^++++ ++++++++++++ +++++++++^^^ ^^++++++++++

file-2 contains indexes line line:

1 3 5 explaination: rs='' tell awk read multi-line records nr==fnr read file-2 one-line, should split \n, , save result in array a next skip rest commands, ready read file-1 $1 in a test whether file-1's 1st column in array a file-{2,1} should read file-2 first indexes

linux sed awk

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -