Fli
03-20-2018, 07:59 AM
I have found this method, so i want to share it.
If you are for example listing some log file using cat, tail, head and you want to remove first few columns from the output, you can try:
awk '{$1=$2="";print}' filename
or
cat filename|awk '{$1=$2="";print}'
it will not modify file, it will just narrow the output. (remove first and second column)
To really delete the columns from file, redirect output to a new file:
cat filename|awk '{$1=$2="";print}' > newfile
To exclude different columns, just replace $1 anb $2 by column numbers to exclude from output.
If you want to show only one column (example second), try: awk '{print $2}'
If you are for example listing some log file using cat, tail, head and you want to remove first few columns from the output, you can try:
awk '{$1=$2="";print}' filename
or
cat filename|awk '{$1=$2="";print}'
it will not modify file, it will just narrow the output. (remove first and second column)
To really delete the columns from file, redirect output to a new file:
cat filename|awk '{$1=$2="";print}' > newfile
To exclude different columns, just replace $1 anb $2 by column numbers to exclude from output.
If you want to show only one column (example second), try: awk '{print $2}'