If I have really long output from a command (single line) but I know I only want the first [x] (let's say 8) characters of the output, what's the easiest way to get that? There aren't any delimiters.
|
One way is to use
This will give you the first 8 characters of each line of output. Since |
|||||
|
|
These are some other ways to get only first 8 characters.
And if you have bash
|
|||
|
|
If you have a sufficiently advanced shell (for example, the following will work in Bash, not sure about dash), you can do:
After executing Explanation: the Finally, we do Another option is to do all your processing inside the subshell. For example:
|
|||
|
