I came across this method of concatenating strings while
studing for a test. It accomplishes the same thing as some
of the previous posts.
20:08:07 | cat testfile
alpha
beta
gamma
delta
20:08:17 | nawk '{list=list" "$1}END{print list}' testfile
alpha beta gamma delta
r063r7
I am not sure if you meant to delete the last character of every line or the last character of the file. This should delete newline characters from the end of each line:
02:35:17 | cat dog
filename=$1
awk '{printf("%s ",$0)};END{print}' $filename
02:35:24 | cat testfile
alpha
beta...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.