On Fri, Feb 26, 2010 at 04:27:16PM -0600, Blues Renegade wrote: > I need help getting the printf command to properly format a multi-line > "Usage:" message I've put in a bash shell script. > > # Usage message assigned to var, USAGE > USAGE="\nUsage: `basename $0` [DIRECTORY]\n\n"\ > "NOTE:\tIf no directory is specified, `basename $0`\n"\ > "\tstarts searching in the current directory.\n"\ > "\tSearch results are displayed on-screen and\n"\ > "\twritten to the file, 'dupes-found.txt',\n"\ > "\tin the top-level search directory.\n" > > # Using %b printf correctly translates the escape sequences, > # but strips all the white space out of the message. > printf "%b" $USAGE > > # echo -e $USAGE will show you how I intend this message to look. ;) > # When using echo -e and creating the $USAGE message with spaces > # instead of /t tab chars escaped, all the spaces were stripped but one. > > I've always been lazy and used echo, but it's time I step up to printf > and gain more control of my output. > > TIA for any help, suggestions, links, you can provide! > > John > > > > -- > You received this message because you are subscribed to the Linux Users Group. > To post a message, send email to [email protected] > To unsubscribe, send email to [email protected] > For more options, visit our group at > http://groups.google.com/group/linuxusersgroup
printf "%b" "$USAGE" It was treating every word in 'USAGE' as a separate argument, and concatenating them together. -- You received this message because you are subscribed to the Linux Users Group. To post a message, send email to [email protected] To unsubscribe, send email to [email protected] For more options, visit our group at http://groups.google.com/group/linuxusersgroup
