1) Limit the output to 'n' characters per line in a search .
In the above example, it is limited to 400 bytes.
cat sample_file.log | cut -b 1-400 | less
2) In a large file, count the total lines starting with ^1 in the first column
sed '1 d' FILE.csv | cut -d',' -f1 | sort | grep '^1*' | wc -l
sed '1 d' - delete the first line i.e. the header generally in a CSV
FILE.csv - File in question to analyze
cut -d',' -f1 - Split the file using the ',' as a separator ('d','), and then retain the first column (f1)
sort - order the output in ascending manner
wc -l - total number of lines in the file
No comments:
Post a Comment