Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Echo does not work to append to a new line Post 302917282 by vikatakavi on Monday 15th of September 2014 04:39:39 PM
Old 09-15-2014
Echo does not work to append to a new line

Hi,

i am witing a function in a shell script which will echo the file name and witre in to the new line, but i dont get expected results. The below is my code

Code:
#!/bin/bash
DATE=$1
myview(){
base_name=$1
echo -ne "${base_name}${DATE}">>  /path/to/file/txt
}
myview sample3030
myview sample2020

i am excepting results as

Code:
sample303020140101
sample202020140101

But i get the results as

Code:
sample303020140101 sample202020140101


any idea what i am doing worng would help me.

Thanks

Last edited by Scrutinizer; 09-15-2014 at 05:56 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

echo, append to end of file

I need the line printed with echo to append to eof of to exactly line, am i able to do that? i mean echo "sysctl -w lalala=1" > to end of file /etc/sysctl.conf or to the 21st line, if the line exist, open new line and insert text there. Thx.maybe i'm in wrong topic but anyway... (2 Replies)
Discussion started by: hachik
2 Replies

2. UNIX for Dummies Questions & Answers

bash pattern matching echo *[! '/' ] doesn't work

without using ls, just using echo so purely pattern matching I can say echo */ <-- lists directories but how would I match files? surely something like *!/ or * but neither work ? it seems like there isn't much that I can put in but surely i should be able to put any ascii... (1 Reply)
Discussion started by: james hanley
1 Replies

3. Shell Programming and Scripting

Append Status to echo'd line after process completes

Hello All, I'm very new to scripting and I'm writing a very simple script to restart a couple processes because I'm getting to lazy to cd between directories. This is pretty much my first script and I just want to add a little cosmetics to it. Here's what I have: #!/bin/ksh echo... (5 Replies)
Discussion started by: Setan
5 Replies

4. Shell Programming and Scripting

if [ -z echo foo | egrep -e 'regexp' != '' ] -> dont work

Hallo, I need to test a String (a special ip number-string). So I want to run that: ipadress=172.0.0.0 # for debugging: echo $ipadress | egrep -e '172\.?\.??\.??$' # the test that doesnt work if test -z `echo $ipadress | egrep -e '172\.?\.??\.??$'` != "" then echo "match" else... (1 Reply)
Discussion started by: wiseguy
1 Replies

5. Shell Programming and Scripting

echo $PWD doesn't work

I have entry in the my .profile like below, but still i see $PWD is not defied in my system export PS1=$LOGNAME@`hostname`':'$PWD'>' echo $PWD also gives me nothing, my env list also give no entry for PWD.Can someone help me setting PWD variable. I use /bin/sh (9 Replies)
Discussion started by: yesmani
9 Replies

6. Shell Programming and Scripting

shell script, echo doesn't work

#!/bin/sh something(){ echo "Inside something" echo $1 $2 } val=$(something "Hello " "world") Output expected: Inside somethingHello world But it's not echoing. (4 Replies)
Discussion started by: cola
4 Replies

7. UNIX for Dummies Questions & Answers

'echo dir_path | xargs cd' does not work?

Hi: how come this command does not work? the error message is: xargs: cd: No such file or directory yet, in the same time, 'echo dir_path | xargs ls' works. Does it work in bash? We use csh. Thanks. NB Phil (7 Replies)
Discussion started by: phil518
7 Replies

8. Shell Programming and Scripting

Color on echo output does not work

Hi, When I run: echo "\033I see hi in color, but if I run this color is not shown, why? (echo "\033Thanks Israel. ---------- Post updated at 05:17 AM ---------- Previous update was at 04:43 AM ---------- DONE!! I had to run more -v. Thanks (4 Replies)
Discussion started by: iga3725
4 Replies

9. Shell Programming and Scripting

echo doesn't work right

Hi,when I run my first shell script,I got something that doesn't work right. I wrote this code in the script. echo -e "Hello,World\a\n"But the screen print like this: -e Hello,World The "-e" wasn't supposed to be printed out. Can anyone help me out?:wall: Many thanks!:) (25 Replies)
Discussion started by: Demon
25 Replies

10. Shell Programming and Scripting

SED and Solaris Append line to the end of File does not work

Hello, I have to add a new line at the end of a File on Solaris-System: I think my script should be right, because I evaluated it to other threads. However the script does not what I am expected it should do. My file might look like this: Line1 Line2 Line3 And my script could... (7 Replies)
Discussion started by: Timo_HR
7 Replies
ECHO(1) 								FSF								   ECHO(1)

NAME
echo - display a line of text SYNOPSIS
echo [OPTION]... [STRING]... DESCRIPTION
NOTE: your shell may have its own version of echo which will supercede the version described here. Please refer to your shell's documenta- tion for details about the options it supports. Echo the STRING(s) to standard output. -n do not output the trailing newline -e enable interpretation of the backslash-escaped characters listed below -E disable interpretation of those sequences in STRINGs --help display this help and exit --version output version information and exit Without -E, the following sequences are recognized and interpolated: NNN the character whose ASCII code is NNN (octal) \ backslash a alert (BEL)  backspace c suppress trailing newline f form feed new line carriage return horizontal tab v vertical tab AUTHOR
Written by FIXME unknown. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for echo is maintained as a Texinfo manual. If the info and echo programs are properly installed at your site, the command info echo should give you access to the complete manual. GNU coreutils 4.5.3 February 2003 ECHO(1)
All times are GMT -4. The time now is 05:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy