tar -tvf file.tar
contains log files.
Is there anyway to do something like this
tar -tvf file.tar | head -1 | awk '{print $NF}' | xargs less {}
This would give file not found, but is there a way?
linuxtar
tar -tvf file.tar
contains log files.
Is there anyway to do something like this
tar -tvf file.tar | head -1 | awk '{print $NF}' | xargs less {}
This would give file not found, but is there a way?
Best Answer
If you don't use the
v
switch withtar
, you'll just get a list of file names, not anls -l
listing.I'm assuming you only want to look at the first file from the
head -1
so
Will work to view the first file
That last switch is an uppercase 'O' Oh not 0
-O, --to-stdout
extracts files to standard outputIf you want to view them all at once
But you'll lose the exact name of the log file you're viewing