bash: how to execute a line from a file? -
i guess easy couldn't figure out. have command history file , i'd grep line , execute it. how do it?
for example: in file command.txt file, there is:
wc -l *txt| awk '{ofs="\t";print $2,$1}' > test.log
suppose above line last line, want this
tail -1 command.txt | "execute"
i tried use
tail -1 command.txt | echo
but no luck.
can tell me how make work?
thanks!
just use command substitution
bash -c "$(tail -1 command.txt)"
Comments
Post a Comment