Visit Our UNIX and Linux User Community

[Solved] Output on one line

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Output on one line
# 1  
Old 08-19-2013
[Solved] Output on one line

A simple question, but i am finding it diffcult to find the answer.

Can you please tell me how i can get the output of two line on one.

I am aware i need to enter \ something, but no sure which charcter, can you advice.


for i in `cat LDN_HOSTS_190813 | grep -i LDN | awk '{print $1}' | sort -u `
        echo "$i" ; bpimagelist -client $i -d 08/14/2013 18:00:00 -U | egrep -vi "Expires|-" | awk '  { if($5 > 1000000) print $0} ' | awk 'NR==1{print $1,$2,$5,$10,$11}'

Output currerntly
08/16/2013 20:23 1577925 LDN_WAT_UX_DEV
08/18/2013 23:50 2575795 LDN_CAM_UX_PRD

Output required
algomd01    08/16/2013 20:23 1577925 LDN_WAT_UX_DEV
allocp01      08/18/2013 23:50 2575795 LDN_CAM_UX_PRD

# 2  
Old 08-19-2013
For awk i think you can use
printf ("%s", $0)

instead of
print $0

Hope it helps.
# 3  
Old 08-19-2013
Try this

for i in `cat LDN_HOSTS_190813 | grep -i LDN | awk '{print $1}' | sort -u `        do        echo "$i `bpimagelist -client $i -d 08/14/2013 18:00:00 -U | egrep -vi "Expires|-" | awk '  { if($5 > 1000000) print $0} ' | awk 'NR==1{print $1,$2,$5,$10,$11}'`"

# 4  
Old 08-19-2013
Sorry did not work... Same output as before capitanui and prasperl

Last edited by Junes; 08-19-2013 at 08:56 AM..
# 5  
Old 08-19-2013
Please try the below given code in your shell..just to want to see the outcome

echo "I am `whoami`!"

# 6  
Old 08-19-2013
# echo "I am `whoami`!"
I am root!

---------- Post updated at 01:00 PM ---------- Previous update was at 12:57 PM ----------\c\c
08/16/2013 20:23 1577925 LDN_WAT_UX_DEV
# 7  
Old 08-19-2013
Thats good..My suggestion was also on the same logic...I guess your "$i" itself has a \n
...My suggestions
for i in `cat LDN_HOSTS_190813 | grep -i LDN | awk '{print $1}' | sort -u `
        echo -n "$i"
echo  "`bpimagelist -client $i -d 08/14/2013 18:00:00 -U | egrep -vi "Expires|-" | awk '  { if($5 > 1000000) print $0} '`"


for i in `cat LDN_HOSTS_190813 | grep -i LDN | awk '{print $1}' | sort -u `
        var1=`echo "$i" | tr -d '\n'`
var2=`bpimagelist -client $i -d 08/14/2013 18:00:00 -U | egrep -vi "Expires|-" | awk '  { if($5 > 1000000) print $0} '`"
echo "$var1 $var2"

Previous Thread | Next Thread
Test Your Knowledge in Computers #909
Difficulty: Easy
In computer science, a pointer is a programming language object that stores the memory address of another value located on a hard drive.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

2. HP-UX

[Solved] Weird 'ls -l' output

Hello folks, I've found an HP-UX server with a rare 'ls -l' output. Please see the attached file. Anybody knows how can I change the output to not have this extra tabulations? Thanks in advance! (10 Replies)
Discussion started by: carpannav
10 Replies

3. Shell Programming and Scripting

[SOLVED] Want to remove output from a command

Hi, I'm on AIX 5.2. I wrote a script that makes a traceroute to a host. The script works fine but each time it using the traceroute command its generate the 2 output lines. this is the command in my script traceroute -n -m 5 -w 2 $Host | grep 172 | awk '{print $2}' | tail -1 traceroute... (2 Replies)
Discussion started by: ce9888
2 Replies

4. Shell Programming and Scripting

[Solved] How to separate one line to mutiple line based on certain number of characters?

hi Gurus, I need separate a file which is one huge line to multiple lines based on certain number of charactors. for example: abcdefghi high abaddffdd I want to separate the line to multiple lines for every 4 charactors. the result should be abcd efgh i hi gh a badd ffdd Thanks in... (5 Replies)
Discussion started by: ken6503
5 Replies

5. Programming

[SOLVED] C++ print next line until line.empty

Hi, could you please help with the following: I have an input file like: one two three four five six I want to print the lines starting from 'three' to the empty line. Something like that: if ( line == "three" ) { while ( !line.empty() ) { cout <<... (0 Replies)
Discussion started by: apenkov
0 Replies

6. Shell Programming and Scripting

[Solved] Find and append line to output

Hi All, I am trying to write a shell script but not getting desired output. What i am trying to do. 1.I want to use find command command and then use it xargs/exec to append the find output.But i am not getting desired output here is what i am trying to do #find init*.ora -exec `echo... (4 Replies)
Discussion started by: sahil_shine
4 Replies

7. UNIX for Dummies Questions & Answers

[Solved] awk output into a file

Hello board members.. here i am and here is my question. OS HP-UX awk i have a file where the FS is the pipe (|). So i choose the second field and i would like to do the following: If this filed is 0 then, i need the line in file1.txt Else write the line in file2.txt cat testfile.txt |... (2 Replies)
Discussion started by: kiko
2 Replies

8. Shell Programming and Scripting

[Solved] making each word of a line to a separate line

Hi, I have a line which has n number of words with separated by space. I wanted to make each word as a separate line. for example, i have a file that has line like i am a good boy i want the output like, i am a good (8 Replies)
Discussion started by: rbalaj16
8 Replies

9. Shell Programming and Scripting

[Solved] Read a .gz file line by line without using gzcat

Hi all Is there a way to read and process a gzip file line by line similar to a text file without using gzcat.. while processing a text file we will usually use the logic exec<sample.txt while read line do echo $line done Is there a similar way to process the gz file in the same... (4 Replies)
Discussion started by: aikhaman
4 Replies

10. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

Featured Tech Videos