3 ms·
Cut has flags to extract byte or character ranges. You don't have to use fields.
by lelanthran 1y ago
Cut has flags to extract byte or character ranges.
You don't have to use fields.
- sudahtigabulan 1y agoCan these flags be used to extract the N-th column (say, the size) of every line from ls -l output?
- lelanthran 1y agoYes. $ ls -l | cut -c 35-41 22 4096 4096 4096 4096 4096 4096 68 456 690 7926 8503 19914
- sudahtigabulan 1y agoThis is what I get: ls -l | cut -c 35-41 6 Nov 1 6 Nov 6 Nov 1 6 Nov 1
- lelanthran 1y agoWell, sure. I said it did character ranges so you don't have to use fields. What were you expecting? That your character ranges in ls would match mine?
- sudahtigabulan 1y ago> What were you expecting? That your character ranges in ls would match mine? I would expect the command to work in any directory. Try a few different directories on your computer and you'll see that it won't work in some of them.
- lelanthran 1y ago> I would expect the command to work in any directory. But ... why expect that? That's not what "character ranges" mean. I mean, I was only trying to clarify that `cut` is not limited to fields only.