5 ms·
> I just don't understand what "can split text into lines" is, do you mean that the selected fields can be split into lines? Good question, I struggle to word
by riquito 4y ago
> I just don't understand what "can split text into lines" is, do you mean that the selected fields can be split into lines?
Good question, I struggle to word it properly, any help is appreciated.
Assume a file (we will call it "input"), such as
first line here
followed by second line
You can use a delimiter and cut inside each line
e.g.
$ tuc -d ' ' -f 2 < input
line
by
or you can cut it "by lines", practically considering the whole file as your single "line" and using newline as delimiter
$ tuc -l -f 2 < input
followed by second line
If you want to remove a line, or keep something inbetween it can be more practical/intuitive than head/tail or sed
- forty 4y agoThis feature seems more like a replacement for head and tail (and combination of both) rather than cut. Maybe a good way to explain it would be to show how to achieve the same thing with those well known commands (comparison which should certainly be in favor of tuc ^^) EDIT: sorry you just said more or less the same thing, I need to read better :)
- renewiltord 4y agoYou could have it do "every 5th line". Easy with awk but this is more compact
- tyingq 4y agoSed is terse for that, but not very memorable...sed -n '0~5p' filename
- renewiltord 4y agoGood tip. Thanks.
- I_complete_me 4y agoRef. your $ tuc -d ' ' -f 2 < input how is different from $ cut -d ' ' -f 2 input ?
- riquito 4y ago> Ref. your $ tuc -d ' ' -f 2 < input how is different from $ cut -d ' ' -f 2 input ? It's not. `tuc` is a superset of cut and in that particular example there's no difference. If you wanted instead to cut on multibyte delimiters, or on a random amount of spaces, `tuc` would work, while `cut` would fall short
- I_complete_me 4y agoI was responding in good faith to your response "Good question, I struggle to word it properly, any help is appreciated." You answered masklinn's with an implementation of your tool that `cut` would also do. That is what I was highlighting. I was not trying to belittle your utility, I have even installed it. But I also don't communicate perfectly so we'll call it evens?
- riquito 4y agoDon't worry, I was in good faith too, it's hard to convey some things sometime. I tried to answer masklinn's question with a simple example, didn't really think about whether it would have showcased tuc or not. Thanks for trying it out!