Re: command tr
> I use tr command and rearrange the date of the file from column to row
> But there are two spares between data as follows
> Do you have any idea and I want to get one space between data
>
> # cat file | tr '\n' ' ' > file2
First you don't need the 'cat' here. It serves no useful purpose. I
see a lot of people do that as a bad habit.
Second I think you want to squeeze repeated newlines and then
translate them to spaces.
tr -s "\012" " " < file
If you need to restore a single final newline, we translated them to
spaces here, then we can use echo.
tr -s "\012" " " < file ; echo
I am only using "\012" here since '\n' is shell specific but "\012"
works on older more traditional unix systems. If '\n' works for you
then I would keep using it.
HTH
Bob
> #more file2
> hvaca backus brinnal christiawe
>
> origainl file:
>
> hvaca
>
> backus
>
> brinnal
>
> christiawe
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: