need simple echo question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need simple echo question
# 1  
Old 09-27-2012
MySQL echo output question

Hi

I want to use echo command as below

HTML Code:
echo 'dir=' $1 ' dir|file|home'
i need output like below :

Code:
echo 'dir=' $1 ' dir|file|home' pp13dff

Output

Code:
dir=pp13dff dir|file|home


Last edited by asavaliya; 09-27-2012 at 09:39 PM..
# 2  
Old 09-27-2012
That isn't the way echo works. You could put the echo in a shell script and invoke the script with the last parameter you're giving to echo as a parameter to the script, but the following is probably closer to what you want:
Code:
var=pp13dff
printf "dir=%s dir|file|home\n" "$var"

If pp13dff isn't in a variable this doesn't make much sense. If you have the string you want to echo when writing the echo, why not just use:
Code:
echo 'dir=pp13dff dir|file|home'


Last edited by Don Cragun; 09-27-2012 at 09:44 PM.. Reason: missing "
# 3  
Old 09-27-2012
Bug

I know my friend ,

But I want use awk or echo command so i can run with single line//

Thanks for your time men!!!
# 4  
Old 09-27-2012
So, if you want that output from echo, use the code I showed you in my last message. If you want a single line awk program to do it, try:
Code:
awk 'END {print "dir=" var " dir|file|home"}' var=pp13dff /dev/null

It sounds very much like you don't understand the concepts of a shell and positional parameters. If you need help with these basic concepts, you should probably be posting questions in the UNIX for Dummies Questions & Answers forum instead of the Shell Programming and Scripting forum (which assumes more advanced knowledge of basic shell operations and parameter passing).
# 5  
Old 09-27-2012
The command that was given to you was a single line.

Even better, it's a single-line shell builtin.

I have no idea what you'd expect awk or echo to help with here.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

2. Shell Programming and Scripting

Simple cat and echo question

Apologies, probably a really simple problem: I've got a text file (nh.txt) with this in it: user1 email1 email2 user2 email1 email2 etc With the following basic script: for tline in $(cat nh.txt) do echo "**********" echo $tline done ... (3 Replies)
Discussion started by: nelmo
3 Replies

3. Shell Programming and Scripting

Simple echo problem

Hey all! I'm in an intro to UNIX class at university, and we've just began writing scripts. Naturally I can't get it to do what I want. Basic script as follows: COMPARE1=`ls|wc -l` tar czf archive.tgz ~/path/to/file COMPARE2=`tar tvzf archive.tgz|wc -l` if then ... (7 Replies)
Discussion started by: nickzourdos
7 Replies

4. Shell Programming and Scripting

"Simple" echo/reading variable question...

Hello, I have a simple(I think) question! Although simple, I have been unable to resolve it, so I hope someone can help! OK, here it is: 1)I have an awk script that prints something, such as: awk '{print $2}' a > x so x might hold the value of say '10' 2)Now, I just want to check to see if... (4 Replies)
Discussion started by: astropi
4 Replies

5. UNIX for Dummies Questions & Answers

echo * question

Hi all and tks in advance I am working my way through 'Learning the bash Shell'. I cannot be sure if I really understand why "echo *" (my double quotes) returns all the files in the current directory. I get the * ( wildcard) expansion of "*", and I think I understand that "echo" returns it's... (5 Replies)
Discussion started by: mdeh
5 Replies

6. Shell Programming and Scripting

With that logic this echoes "echo". Question about echo!

echo `echo ` doesn't echoes anything. And it's logic. But echo `echo `echo ` ` does echoes "echo". What's the logic of it? the `echo `echo ` inside of the whole (first) echo, echoes nothing, so the first echo have to echo nothing but echoes "echo" (too much echoing :P):o (2 Replies)
Discussion started by: hakermania
2 Replies

7. Shell Programming and Scripting

Echo question

How can I get the following to prompt me for new values for the dacsrtrspans? example I want to change the span #, sinktermmod, sinktermport, srctermdev and srctermport to new values. old: ADD DACSRTRSPAN-1-840 SINKTERMMODULE=8 SINKTERMPORT=94 SRCTERMDEV=1 SRCTERMPORT=1 SPANTYPE=T1_2... (0 Replies)
Discussion started by: tadzooks
0 Replies

8. Shell Programming and Scripting

An echo question

Why do get 0 when i enter " echo $? " (1 Reply)
Discussion started by: JamieMurry
1 Replies

9. UNIX for Dummies Questions & Answers

Simple 'echo' question

Hi, I would like to output the identical line to 2 text files, ie output='blah' echo $output > test1.txt echo $output > test2.txt Is there a way I could do that output with ONE command, ie output='blah' echo $output > test1.txt & test2.txt (I know that doesn't work) Thanks for any... (1 Reply)
Discussion started by: msb65
1 Replies

10. UNIX for Dummies Questions & Answers

Ok simple question for simple knowledge...

Ok what is BSD exactly? I know its a type of open source but what is it exactly? (1 Reply)
Discussion started by: Corrail
1 Replies
Login or Register to Ask a Question