I noticed something with the cut
command today, which somehow I had never noticed before, even though I have been using and working with them for a long time.
From string /users/developer/
, I wanted to extract users
. So, what I did was,
echo `pwd` | cut -d '/' -f1
This was not returning me anything. My assumption was, since I had specified /
as a delimiter, it should have returned me the first field after the delimiter is found.
After a bit of tweaking, I realized that I can get my desired output, when I change my command to retrieve f2
echo `pwd` | cut -d '/' -f2
It led me thinking, that delimiter always expects something to be on the left side of it, and that is why, on trying to retrieve the first field, it was not returning me anything, and when I tried to retrieve second field, I got what I was expecting.
Logically, it makes sense for a delimiter
. I just wanted to know, is that really how the delimiter parameter works in cut command? In other words, is my inference correct (that delimiter always expects something to be on the left of delimiter)