Echo working funny


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Echo working funny
# 8  
Old 06-23-2009
your print statement in the awk is culprit...when you do
Code:
print $word_count

it prints $word_count , each in a new line
instead use

One more thing from your while loop
Quote:
while (word_count <= NF) {

print $ word_count

word_count++
You should have told more clearly what you wanted from this while loop...
may be this...
Code:
$(word_count)=word_count

in this case use print in the
Code:
END {print}.

# 9  
Old 06-23-2009
Quote:
Originally Posted by methyl
Not sure what you were trying to achieve here but beware that "swlist" on its own lists the bundles. Each bundle can contain multiple packages.
What we are doing is a software audit of a HP-UX system. Do you think that is better to use

swlist -l product


for example? We have to compare it with the licenses purchased and we thought that it would be easier to compare with the bundles. Because that's the way the software is purchased, isn't it?

Thanks again!

---------- Post updated at 08:20 AM ---------- Previous update was at 08:16 AM ----------

Quote:
Originally Posted by rakeshawasthi
your print statement in the awk is culprit...when you do
it prints $word_count , each in a new line
instead use

One more thing from your while loop

You should have told more clearly what you wanted from this while loop...
may be this...
in this case use print in the
(code parts ripped by me)

I did this while loop because I need to print all the columns beginning in the 3rd one till the end of the line, from a text with multiple lines.

Why to do it like that? Because the name of the software products have multiple words, and they are different from one to another, so I use NF to reach the end of the line!

And, of course, because I don't know any better way to do it! I'm a newbie!

Thanks for your suggestions!

---------- Post updated at 09:24 AM ---------- Previous update was at 08:20 AM ----------

Again, I will answer myself:

It's better to use swlist -l product

This will list all the software installed.

Another thing, about the AWK while loop I put there, for better functionality I have added another pipe to head -1, to take just the first coincidence of the string.

The problem was that some software names where also "inside" other software names, for example:

Program1
Program12

When I do grep 'Program1', I get both as the result. If somebody is thinking about some parameter, HP-UX is SO limited about it, if you compare it with Linux for instance.

With grep 'Program1' | head -1 I take just the first result, which is the one I want!

Thank you all.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Echo command not working in the script

HI I have and echo command which works perfectly in the shell but when i execute in the script it gives me an error code query is as below QUERY=`echo "Select Severity,Dupl_count,Creation_Time,Last_Received,Node_Name,Node_Name,Object,Message_Group,Message_Text,Last_Annotation from " \ ... (2 Replies)
Discussion started by: Jcpratap
2 Replies

2. Shell Programming and Scripting

Echo not working with $

$cat FILE.txt $PATH1/file1.txt $PATH2/file2.txt where$PATH 1 = /root/FILE_DR/file1.txt $PATH 2 = /root/FILE_DR/file2.txt for I in `cat FILE.txt` do v=`echo $I` echo $v if then rm $v (5 Replies)
Discussion started by: ekharvi
5 Replies

3. Shell Programming and Scripting

echo two variables like the paste command is not working

Dear all, I have two files like this file1 A B C D E F file2 1,2 3,4 5,6 I want this output output_expected A B 1,2 C D 3,4 E F 5,6 (3 Replies)
Discussion started by: valente
3 Replies

4. Shell Programming and Scripting

echo is not working as expected

for i in `cat /export/home/afahmed/Arrvial_time.txt` do echo $i echo $i | awk '$3 < $D { print $4 }' >> dynamic_DF.txt; done When i echo, its echo as Nov 15 02:24 /export/home/pp_adm/inbound//wwallet_20111115.txt where i expect it to be Nov 15 02:24... (7 Replies)
Discussion started by: afahmed
7 Replies

5. What is on Your Mind?

Old, but still funny

Annoyances.org - Upgrading to Wife 1.0 (0 Replies)
Discussion started by: jgt
0 Replies

6. Shell Programming and Scripting

why the set rr='echo string|cut not working

I am new to the c shell script, can you let me know why the set rr= is not working. C shell script #! /bin/csh Set tt= 12345_UMR_BH452_3_2.txt set rr='echo $tt | cut –d”_” -f1' syntax error (4 Replies)
Discussion started by: jdsignature88
4 Replies

7. UNIX for Dummies Questions & Answers

Is echo $variable >> text.txt working in MacOSX?

Hi New at this, but want to learn more. I'm trying this as an Shell Command in MacOSX; newdate='<TIME>' echo $newdate >> /Users/ttadmin/Desktop/test.txt And it don't work. But if I just use; echo <TIME> >> /Users/ttadmin/Desktop/test.txt (<TIME> is an variable that one program... (6 Replies)
Discussion started by: jackt
6 Replies

8. UNIX for Dummies Questions & Answers

Funny but true....

Hallo everybody I am having a shell script called auto_run.sh in that only the first line works. the second line which has sed command is working only at the # prompt. not within the shell script. What could be the reason. *... sed 's/ //g' KTI >abc works in another shell script without the... (6 Replies)
Discussion started by: naushad
6 Replies
Login or Register to Ask a Question