I had the following problem. I was analyzing a dump of a Java process. There was a String object taking a few hundred megabytes of heap. I saved it to a file and wanted to look at it. This string contained a few hundred lines many of them were very long. It’s not so easy to scroll through such a file. Actually, only the beginning of each line was interesting since the rest of the line contained only a huge list of ascii codes.
Here is how you get only the first 30 characters of each lines:
cut -c1-30 INPUT_FILE_PATH > OUTPUT_FILE_PATH
It’s actually pretty easy ! Just love how much you can actually do with a one liner as soon as you’ve found out whether you need to use grep, awk, sed, cut, tr or a combination of them !