01-07-2015
The behavior of echo varies considerably from system to system, shell to shell, and with various environment variable settings when there are any backslash (\) characters in any of the arguments and when the 1st character of the 1st argument is a minus sign (-) character. Using printf instead of echo in these conditions will prevent lots of headaches later if you ever move to a different environment or if some other user with a different shell or environment variables tries to use your code.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi everyone,
I was told, i my job, to do a script that creates the backup of all the files that are important to us.
So i created the script, put it in the crontab and it works great.
Now what i want is to write to a file what directories have being copied with date and time.
How can i... (3 Replies)
Discussion started by: jorge.ferreira
3 Replies
2. Shell Programming and Scripting
Morning All,
Quite a simple one this, I hope. What I want to do is to re-write the first line of a file before it's sent to print. The line will be blank initially, and I want to insert some text. The operation can either be done on the file itself (modifying the file on disk), OR in a... (2 Replies)
Discussion started by: alexop
2 Replies
3. UNIX for Dummies Questions & Answers
I was trying to find out the easiest way to write new line to the beginning of an exisiting file.
I am using KSH. (5 Replies)
Discussion started by: sailussr
5 Replies
4. Shell Programming and Scripting
hi,
i want to write in a file the output of one command and pile also the same output
like ls -lrt > some_file | wc -l (9 Replies)
Discussion started by: narang.mohit
9 Replies
5. Shell Programming and Scripting
Hello Unix Gurus,
Please let me know if this is hard to understand and I apologize for my inability to explain better.
I have a file "Foo" with the following structure
CHR_A BP_A SNP_A CHR_B BP_B SNP_B R2
1 ... (3 Replies)
Discussion started by: genehunter
3 Replies
6. Programming
i am very new to Perl. i am using Ubuntu. i have a string call $string that contains following words "new line". i also have a data file as follows.
djfibjbet
etitrbjijbtr rrge rgjierjegjeri
jerijg
kijij jijij
i want to write my new line to my data file as follows.
djfibjbet... (3 Replies)
Discussion started by: usustarr
3 Replies
7. Shell Programming and Scripting
I have the following:
#! /bin/bash
foo="bar"
this="that"
vars="foovar=$foo\n\
thisvar=$this\n"
I want to write the following to a file:
foovar="bar"
thisvar="that"
Then in another script, I pull this file, and loop through it:
while read line; do
eval $line
done <... (3 Replies)
Discussion started by: Validatorian
3 Replies
8. Shell Programming and Scripting
I have list of files in a directory 'dir'. Each file is of type HTML. I need to read each file and get the string which starts with 'http' and write them in a new text file. How can i do this shell scripting?
file1.html
<head>
<url>http://www.google.com</url>
</head>
file2.html
<head>... (6 Replies)
Discussion started by: vel4ever
6 Replies
9. Shell Programming and Scripting
dear all,
i need your advice
i have sample script like this:
testing.sh
for i in {1..10}
do
echo testing $i
done
but i forgot create "#!/bin/bash" in above "for"
so i want output will like this
testing.sh
#!/bin/bash
for i in {1..10}
do
echo testing $i
done (2 Replies)
Discussion started by: zvtral
2 Replies
10. Shell Programming and Scripting
Hi,
I have a file which contains the below details.. My requirement is to fetch all the lines which are starting with "ABC_XY_" into 1 file and rest of the lines (not starting with "ABC_XY_") into another file.
Could you please help with what command needs to be used?
file1.txt
----------... (12 Replies)
Discussion started by: satyaatcgi
12 Replies