Sponsored Content
Operating Systems Linux Availability: echo vs. printf? Post 302924397 by Don Cragun on Sunday 9th of November 2014 07:53:13 AM
Old 11-09-2014
As I have said in dozens of other threads in these forums: if the first character of the first argument is a minus sign, if any argument contains a backslash, if you do not want to have a newline printed at the end of the output, or if any argument contains user-supplied data; use printf, not echo. Otherwise, it doesn't matter whether you use printf or echo.
These 2 Users Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

Printer availability

Hi, Im new in shell programming. I need to know the availability for specific printers. We send requests from solaris to printers located at an NT server. My idea is creating a shell that will monitor availbaility and send an email when something is wrong. I have a file with printers and its... (2 Replies)
Discussion started by: agsarm1971
2 Replies

2. UNIX for Dummies Questions & Answers

How to correctly use an echo inside an echo?

Bit of a weird one i suppose, i want to use an echo inside an echo... For example... i have a script that i want to use to take users input and create another script. Inside this script it creates it also needs to use echos... echo "echo "hello"" >$file echo "echo "goodbye"" >$file ... (3 Replies)
Discussion started by: mokachoka
3 Replies

3. Shell Programming and Scripting

advanced echo/printf

I want to print a colored line using bash. I want to print: Smtp status where "Smtp status" will be in yellow and will be in green. Thanks. (2 Replies)
Discussion started by: proactiveaditya
2 Replies

4. Shell Programming and Scripting

\n in ksh using echo & printf

#!/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

5. Shell Programming and Scripting

printf/echo in a second script

This may be little confusing. I have Script1, which pulls data from the system and creates another script(lets say script2). While I run script1 I need to add printf/echo statements for script2, so that when I run script2 I see those statement. eg: script1 765 printf " display frame-$1 timeoffset... (2 Replies)
Discussion started by: miltonrods
2 Replies

6. UNIX for Dummies Questions & Answers

iscsi high availability

Hi, I want to set up a iscsi high availability with sheepdog distributed storage. Here is my system set up. Four nodes with sheepdog distributed storage and i am sharing this storage through iscsi using two nodes as well as using a virtual ip set up using ucarp.Two nodes using same iqn. And... (0 Replies)
Discussion started by: jobycxa
0 Replies

7. AIX

AIX high availability 1-3/69

Hi, Can someone help and give the answer for the following questions: 1. When PowerHA SystemMirror 7.1 is installed on AIX 7.1, what RSCT component does Cluster Aware AIX (CAA) replace? A. Group Services B. Resource Manager C. Topology Services D. Resource Monitoring and Control... (2 Replies)
Discussion started by: walterchang100
2 Replies

8. Shell Programming and Scripting

Managing output... echo or printf?

Hello script guru's as i write more and more code i always block at managing output... either writing to standard out, writing to files via std out (log, temp file, etc). Don't get me wrong 99% of the time it DOES the job but maybe there is more efficient. I'm writing a small script to... (2 Replies)
Discussion started by: maverick72
2 Replies

9. Shell Programming and Scripting

Grep behaves diffrent upon printf or echo output

Hello I want to check whether certain arguments were passed to the script, and when those are, not doing a log entry. If those arguments are not passed, always do a log entry (*new call*). What currently i have is this: echo "${@}"|grep -q \\- || \ tui-log -e "$LOG" "\r---- New call $$... (4 Replies)
Discussion started by: sea
4 Replies

10. Solaris

High availability

hi guys I posted problem last time I didn't find answer to my issue. my problem is as below: I have two servers which work as an actif/standby in high availability system. but when i use command HASTAT -a i have the following message: couldn' find actif node. the servers are sun... (1 Reply)
Discussion started by: zineb06
1 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.10 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 05:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy