STDOUT in one line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting STDOUT in one line
# 1  
Old 09-03-2010
STDOUT in one line

Hi all,

I got a file which contains this.

Code:
aaaaaaaaaaaaaaaaaaaaaaaa test
aaaaaaaaaaaaaa test
aaaaaaaaaaa test
aaaaaaaaaaaaaaaaa test
aaaaaaaaaaaaaaaaaaaaa test
aaaaaaaaa test
aaaaa test

and I want all test output in one row, ideally 3 spaces after the longest word.
Thanks

Last edited by radoulov; 09-03-2010 at 11:29 AM.. Reason: Code tags, please!
# 2  
Old 09-03-2010
somethng like this:

Code:
 
cat file_name | tr "\n" "  "

# 3  
Old 09-03-2010
Quote:
Originally Posted by stinkefisch
Hi all,

I got a file which contains this.

Code:
aaaaaaaaaaaaaaaaaaaaaaaa test
aaaaaaaaaaaaaa test
aaaaaaaaaaa test
aaaaaaaaaaaaaaaaa test
aaaaaaaaaaaaaaaaaaaaa test
aaaaaaaaa test
aaaaa test

and I want all test output in one row, ideally 3 spaces after the longest word.
Thanks
More like

Code:
aaaaaaaaaaaaaaaaaaaaaaaa test
aaaaaaaaaaaaaa                                test
aaaaaaaaaaa                                     test
aaaaaaaaaaaaaaaaa                           test
aaaaaaaaaaaaaaaaaaaaa                    test
aaaaaaaaa                                         test
aaaaa                                                test

# 4  
Old 09-03-2010
you mean "test" in one column?
Code:
awk '{printf("%80s %s\n", $1, $2) } ' inputfilename

This assumes your data sample is correct: there are only two "words" on a line
This User Gave Thanks to jim mcnamara For This Post:
# 5  
Old 09-03-2010
Perfect thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

STDout

Hi, I have a program set to read in a text file, change certain characters and then print the altered version to the screen but does anyone know how to save the new version as another text file? And, if possible, how to specify the file name, and perhaps location? Thanks! (2 Replies)
Discussion started by: PerlNutt
2 Replies

2. Shell Programming and Scripting

Method to display a line at the top always, regardless of stdout

Hi Is there way to, say, echo a line and make sure it is always displayed on the first line, no matter what is coming out on stdout? eg: #!/bin/bash clear echo " ...... Internal audit script ......" tar xvf hugefile.tar I'd like to have the " Internal audit script " line to be shown... (2 Replies)
Discussion started by: bludhemn
2 Replies

3. Shell Programming and Scripting

stderr/stdout

Can somebody explain to me why the diff output is not going to stderr? Yet when I issue a diff from the command line the return code is -ne 1. I am guessing diff always writes to stdout??? Is there away I can force the difff to write to stderr USING THE CURRENT template. If possible, I... (5 Replies)
Discussion started by: BeefStu
5 Replies

4. UNIX for Dummies Questions & Answers

csplit to stdout

I want to split big files based on a pattern to stdout. Although csplit works well for me splitting the output into separate files (e.g. xx00, xx01, xx02, ...), the following is not working as expected: <code> # assuming pattern occurs less than 100 times csplit bigfile '%pattern%'... (2 Replies)
Discussion started by: uiop44
2 Replies

5. UNIX for Dummies Questions & Answers

replace stdout line in loop

Hi, as part of a script i have a loop that goes though a set of files. This loop can take some time, so i'd like to show the user that something is happening by showing them the filename being worked on. I could create a long list of file names in the terminal using echo or print... (0 Replies)
Discussion started by: nickrick
0 Replies

6. UNIX for Advanced & Expert Users

How to use gzip on stdout

Does anyone know how I can use gzip to zip a large log file on the fly. My simulation is currently logging a large file that I need for analysis at a later point. However the files are so huge that I may even run out of disk space. The content is mainly text so when compressed the files are... (2 Replies)
Discussion started by: mitch1710
2 Replies

7. Shell Programming and Scripting

Executing Stdout ???

Hiya all, Simple question - yet no simple answer im afraid ! Is there a way to execute a shell script (child) which returns one line and get the current (parent) shell to execute the stdout from the child ??? example child.sh #!/bin/sh echo "setenv DISPLAY xxx:03" parent_prompt>... (5 Replies)
Discussion started by: fawqati
5 Replies

8. UNIX for Dummies Questions & Answers

redirect stderr and/or stdout to /dev/null from command line

Is it possible to redirect errors at the command line when you run the script such as bash scriptname & 2>/dev/null? (1 Reply)
Discussion started by: knc9233
1 Replies

9. UNIX for Advanced & Expert Users

STDOUT truncation

Operating system - Solaris 8, Korn shell, xterm Command /usr/proc/bin/ptree outputs the process tree exactly as I want with all detail However, /usr/proc/bin/ptree | more truncates the process descriptions at an 80 character point. If the process tree has marched enough to the right,... (3 Replies)
Discussion started by: JerryHone
3 Replies

10. UNIX for Dummies Questions & Answers

pipe and stdout

Hi there I know that this isn't the place to put a question like this i supose, but i'm geting desperated. I have searched in interbase forums and nothing helped. If anyone can help me i would apreciated. I'm using HP-UX with a version 3 of interbase wich means i can't split the backup file into... (3 Replies)
Discussion started by: vascobrito
3 Replies
Login or Register to Ask a Question