Given columned text in a file that is delimited by a certain character, how do you truncate the width of either a specific column(s) or all columns?
The use case is that I am reading some log files that have space delimited columns. Some of the columns in the log are very long urls that make the file difficult to read. I don't really care about the entire content of the urls, so I would like to truncate the length of these columns to something more readable.
I would be curious to know how to specify specific columns to truncate, but really I only need to figure out how to just truncate all columns of length greater than N.
So far I have found utils column
, colrm
, and cut
, which all seem to be similar to this, but nothing that does what I am looking for.
(Optimally, if there is a compiled utility that already does that, this would be best, but I would also be happy to find a way to do this with sed
, awk
, perl
, etc.)