01-27-2009
echo in ksh sh & bash
Hello,
I have lib file which contain a function that get text to print on screen by echo command.
Several scripts are inculde this lib and use this function.
Each one of them is written in different shell language (sh ksh & bash).
This causing some issues when using backslash charater as part of the test that sends to this function.
I would like to create two echo command which will executed according to the current shell.
How can I extarct the current shell which used by the calling script to the print function ?
Thanks a head
Alalush
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi -
I m prashant. I m new in UNIX&LINUX world. I want to ask that how can we define the shell in Linux like bash,ksh,csh in Linux. What is the use of these shells. I know there are mny experts on net if you can tell me then please do me this favour and tell me about this topic.
... (1 Reply)
Discussion started by: prashantsingh
1 Replies
2. Shell Programming and Scripting
Hi folks,
I need to stop printing a new line after echoing a string in KSH. i know bash provides
echo -n "string"
what is the ksh equivalent for this ? (3 Replies)
Discussion started by: mudhireddy
3 Replies
3. What is on Your Mind?
Same as the Title!
:) (2 Replies)
Discussion started by: ripat
2 Replies
4. UNIX for Advanced & Expert Users
Hi All,
I'm trying to use the "echo" command in a korn shell script, and I want it to drop the trailing newline. Now I know that with the bash shell, the "-n" flag would solve this issue. Does anyone know how this can be done with the korn shell?
Cheers
Khoom (10 Replies)
Discussion started by: Khoomfire
10 Replies
5. Shell Programming and Scripting
hi
i was trying to optimize one script and i came across this problem .. i am putting some pseudo code here
$ >cat a.sh
ls | while read I
do
i=$(($i + 1))
done
echo "total no of files : "
$ >ksh a.sh
total no of files :
$ >bash a.sh
total no of files :
why is... (1 Reply)
Discussion started by: zedex
1 Replies
6. Shell Programming and Scripting
I am using a Linux machine and it's default shell is BASH . I have korn shell script and inside it's setting environment variables. But after execuitng the script those env values are not holding the values . If I run the script outside of that ksh script with source a.sh , it's able to hold to... (1 Reply)
Discussion started by: talashil
1 Replies
7. Shell Programming and Scripting
I am using a Linux machine and it's default shell is BASH . I have korn shell script and inside it's setting environment variables. But after execuitng the script those env values are not holding the values . If I run the script outside of that ksh script with source a.sh , it's able to hold to... (2 Replies)
Discussion started by: talashil
2 Replies
8. Shell Programming and Scripting
I am learning to build from SVN and other tools, with a lot of copying and pasting from forums. I like to append && echo "success" to all commands so that I can see at a glance if things went all right. Is there a way that I can have the bash shell append this to all commands?
Thanks! (5 Replies)
Discussion started by: dotancohen
5 Replies
9. Shell Programming and Scripting
Dear All,
Please advice about this issue.
when i run this line in a script if && || && || && if i enter $x = test3 and $y = test1 the If condition apply while it should not
Best Regards (2 Replies)
Discussion started by: islam.said
2 Replies
10. Shell Programming and Scripting
#!/usr/bin/ksh
var1="Hi World"
var2="Morning"
var3=$(echo "$var1" \n "$var2")
echo $var3
var3=$(printf "$var1 \n $var2")
echo $var3
Output
Any way to get
in my $var3 ? (7 Replies)
Discussion started by: dahlia84
7 Replies
echo(1B) SunOS/BSD Compatibility Package Commands echo(1B)
NAME
echo - echo arguments to standard output
SYNOPSIS
/usr/ucb/echo [-n] [argument]
DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output.
echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi-
ronment variables.
For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows:
o echo your current-working-directory's full pathname
o pipe the output through tr to translate the path's embedded slash-characters into space-characters
o pipe that output through wc -w for a count of the names in your path.
example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w"
See tr(1) and wc(1) for their functionality.
The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if
the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape
characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's
echo() also understands a as the audible bell character; however, these commands do not have an -n option.
OPTIONS
-n Do not add the NEWLINE to the output.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscpu |
+-----------------------------+-----------------------------+
SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5)
NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases.
SunOS 5.10 3 Aug 1994 echo(1B)