converting a list into a line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers converting a list into a line
# 1  
Old 04-02-2001
Hi, this is a pretty intersting problem, I would like to convert a list of words into a concatenated string of words with whitespace between each word.
e.g file list :-
hello
how
are
you
today

convert into
hello how are you today.

What command would I use to do this?

Thanks
# 2  
Old 04-02-2001
here is one trick:

tr "\n" " " < filename #displays on screen

tr "\n" " " < filename >output #redirect to a file

# 3  
Old 04-05-2001
another way to do it :

a=`cat file`
echo $a



greetings...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Converting xls file to xlsx on UNIX script / command line.

Hi All, Am needing advise on how to convert xls file to xlsx format on Solaris unix command line or scripting. I tried searching online but it looks like I need to either use Perl packages of Excel or Python packages or some other 3rd party tool. Problem is to install any of these will require... (2 Replies)
Discussion started by: arvindshukla81
2 Replies

2. Shell Programming and Scripting

Converting another line to another format

Hi there, How can i shorten this: grep -ri "Password must meet complexity requirements" "$line" | sed 's/\t/<\/td><td>/' | sed 's/^.*:/<tr><td>/'| sed 's/$/<\/td><\/tr>/' I am looking for a shorter alternative of sed. What I was trying to do is to change the string output format from ... (3 Replies)
Discussion started by: alvinoo
3 Replies

3. Shell Programming and Scripting

Converting a list to a row to create clusters based on numerical identity

Hello. I have a long list of data which has the following structure The number shows the unique identity of the word. And all homophones are clustered with the same number ID. An example will make this clear The awk script I have allows conversion of a list to row but on condition that each... (4 Replies)
Discussion started by: gimley
4 Replies

4. Shell Programming and Scripting

Converting a list to a row delimited

Hello, I have a large database with the following structure: set of clustered names followed by a hard return and followed by a second set of clustered names and so on. Sometimes the clusters can be as many as 150. Since the data is in an Indian language, a theoretical example will make this... (9 Replies)
Discussion started by: gimley
9 Replies

5. Shell Programming and Scripting

Converting a list to X columns of csv (& wrapping a command around it)

Hi All, Random question, how would you convert a data file from a list like so: 12345 12346 12347 12348 12349 12350 ... <snip 100+ lines> ... to comma separated X columns across: 12345,12346,12347 12348,12349,12350 Why would you want to do this? The background to this is a... (2 Replies)
Discussion started by: craigp84
2 Replies

6. Shell Programming and Scripting

Converting a line into a list using awk or sed

Hello, I am trying to convert a line into a list using awk or sed. Line: 345 897 567 098 123 output: 345 897 567 098 123 thanks (7 Replies)
Discussion started by: smarones
7 Replies

7. Shell Programming and Scripting

Print pipe separated list as line by line in Korn Shell

Korn Shell in AIX 6.1 I want to print the below shown pipe (|) separated list line by line. line=es349889|nhb882309|ts00293|snh03524|bg578835|bg37900|rnh00297|py882201|sg175883 for i in line do echo "Hello $line " done I wanted to execute the above for loop. But i can't even set the... (3 Replies)
Discussion started by: polavan
3 Replies

8. Programming

Converting distance list to distance matrix in R

Hi power user, I have this type of data (distance list): file1 A B 10 B C 20 C D 50I want output like this # A B C D A 0 10 30 80 B 10 0 20 70 C 30 20 0 50 D 80 70 50 0 Which is a distance matrix I have tried... (0 Replies)
Discussion started by: anjas
0 Replies

9. Programming

Reading special characters while converting sequential file to line sequential

We have to convert a sequential file to a 80 char line sequential file (HP UX platform).The sequential file contains special characters. which after conversion of the file to line sequential are getting coverted into "new line" or "tab" and file is getting distorted. Is there any way to read these... (2 Replies)
Discussion started by: Rajeshsu
2 Replies

10. UNIX for Dummies Questions & Answers

converting horizontal line to vertical line

how to use "tr" command to display horizontal line to vertical line for vertical to horizontal, the command is tr '\n' '\t' <inputfile but what is the command for horizontal to vertical Thanks Vasikaran (3 Replies)
Discussion started by: vasikaran
3 Replies
Login or Register to Ask a Question