In order to remove tabs from your output (say to get a specific variable) use the ‘tr’ command, for example
In my zone.file the line containing “Serial” looks like the following:
If I performed
grep Serial zone.file
I would get the following output
2009110904 ; Serial (yyyymmdd##)
You can’t see them here but there are several tabs before that date. In my example I want to get just the actual serial number (2009110904). To do this I’ll first strip off the “; Serial…” information;
grep Serial zone.file | awk -F; {'print $1'}
This command is telling it to look for the ; special character and break up the output there, then from there it is told to print the first column of information this results in:
2009110904
The problem here is that if we want this to be our variable we are actually working with ” 2009110904″ instead of the desired “2009110904” In this particular case we know those are tabs not spaces. So we’ll need to use tr in order to remove those tabs:
grep Serial zone.file | awk -F\; {'print $1'} | tr -d 't'
This will return to us exactly what we want
2009110904