cut command newline

pedr0 picture pedr0 · Mar 6, 2012 · Viewed 65.6k times · Source

I have a file like this:

one
two 
three 
four

I would like use a for loop in a bash script in order to scan the file line for line. Previously I used cut but I was not able to give the cut command the newline delimiter, how can I that?

In this way it does not work :

cut -d'\n' -f1

Any suggestion ?

Answer

Ivan picture Ivan · Feb 13, 2014

I found myself in the same problem, this works for me:

cat file.cut | cut -d$'\n' -f1

Or:

cut -d$'\n' -f1 file.cut