bash - How to using a file as input to program starting from specific line in command? - Ask Ubuntu


to use file input program, < operator can used.

for example,

xmacroplay "$display" < input.txt 

however, there command specify if don't want use whole file, take lines input?

some like,

xmacroplay "$display" < input.txt --starting_line=100 --ending_line=120 

(this surely won't work, want know if there option that)

use sed or tool filter out specific line , pipe command. example, following send 10th , 13th lines of file xmacroplay:

sed -n '10p; 13p' input.txt | xmacroplay "$display" --starting_line=100 --ending_line=120 

or in awk:

awk 'nr == 10 || nr == 13' input.txt | xmacroplay "$display" --starting_line=100 --ending_line=120 

if, reason, cannot use pipe, use process substitution:

xmacroplay "$display" --starting_line=100 --ending_line=120 < <(sed -n '10p; 13p' input.txt) 

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User