I've copied a file from HDFS into my local file system (all on RH linux). However, after the copy, if I cat
the file, I see the following:
[me@ac12 ~]$ cat file_copy
0|name|string
1|phone|string
2|age|string[me@ac12 ~]$
What I expected was this:
[me@ac12 ~]$ cat file_copy
0|name|string
1|phone|string
2|age|string
[me@ac12 ~]$
You can see that a newline seems to be missing in the first cat, and the shell prompt is on the same line as the last line. Why would this be and how can I diagnose the issue?
EDIT: I can't edit the output file (well, maybe I could but I really don't want to - I'd rather fix the problem at the source). I want to know why there is no newline character..
You can use this sed
to add a newline after last line:
sed -i.bak $'$s/$/\\n/' file_copy
EDIT:
Or else use (thanks to @JonathanLeffler):
echo '' >> file_copy
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.