Apr 29, 2003 #1 hallux Programmer Feb 25, 2003 133 US Hi, I would like to use sed to replace all newline characters with spaces, thereby joining all lines into one. Example: Car Bike Scooter Would become "Car Bike Scooter" I tried using "\n", but it didn't work. -Brent
Hi, I would like to use sed to replace all newline characters with spaces, thereby joining all lines into one. Example: Car Bike Scooter Would become "Car Bike Scooter" I tried using "\n", but it didn't work. -Brent
Apr 29, 2003 1 #2 vgersh99 Programmer Jul 27, 2000 2,146 US tr '\n' ' ' < myFile.txt vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
tr '\n' ' ' < myFile.txt vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+
Apr 29, 2003 Thread starter #3 hallux Programmer Feb 25, 2003 133 US Thanks vgersh99, that's exactly what I needed. I also found a 'tr' command to get rid of more unprintable characters: tr -d '\001'-'\011''\013''\014''\016'-'\037''\200'-'\377' < filein > fileout Source: "Very short guide to sed, tr, cut and od" Author: Sakari Mattila I might as well share a little more To see all characters in a file or output, use 'od'. $ echo "hello world" | od -x 0000000 6865 6c6c 6f20 776f 726c 640a 0000014 Notice that h is 68, e is 65 , l is 6c, o is 6f, etc $ echo "hello world" | od -c 0000000 h e l l o w o r l d \n 0000014 $ echo "hello\t world" | od -c 0000000 h e l l o \t w o r l d \n 0000015 -Brent Upvote 0 Downvote
Thanks vgersh99, that's exactly what I needed. I also found a 'tr' command to get rid of more unprintable characters: tr -d '\001'-'\011''\013''\014''\016'-'\037''\200'-'\377' < filein > fileout Source: "Very short guide to sed, tr, cut and od" Author: Sakari Mattila I might as well share a little more To see all characters in a file or output, use 'od'. $ echo "hello world" | od -x 0000000 6865 6c6c 6f20 776f 726c 640a 0000014 Notice that h is 68, e is 65 , l is 6c, o is 6f, etc $ echo "hello world" | od -c 0000000 h e l l o w o r l d \n 0000014 $ echo "hello\t world" | od -c 0000000 h e l l o \t w o r l d \n 0000015 -Brent