multiple echo statements in if condition


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting multiple echo statements in if condition
# 1  
Old 03-12-2011
multiple echo statements in if condition

Hi ,
I have a peculiar problem.

i have an if block like this

Code:
if [ -f $ff ];
then
echo " todays date is " ${date} >> log_file
echo " file count is  " $ count >> log_file
mv filename1 filename 2
else 
echo "no files available ">> log_file
fi

the echo statement "no files available " is not written to the log file if no files are retrieved by the if loop.
Can someone help resolve this and really fast?

Thanks in advance
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 03-12-2011 at 03:08 PM.. Reason: code tags, please!
# 2  
Old 03-12-2011
Code:
if [ -f $ff ];
then
echo " todays date is " ${date} >> log_file
echo " file count is  " $count >> log_file
mv filename1 filename2
else 
echo "no files available " >> log_file
fi

You have "space" problems Smilie
And maybe you want to replace ${date} by $(date)
# 3  
Old 03-12-2011
hi,
what space problems would you be referring to?

thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using multiple 'for' statements

Hello, I am new to scripting and I am trying to write a simple script that creates users and adds their passwords from two files; one a user list file and another a password list file. For example, I have two files already. $ cat file1 andy stephane aby paul $ cat file2 123 234... (4 Replies)
Discussion started by: FemoTheDon
4 Replies

2. UNIX for Dummies Questions & Answers

Multiple if statements

exmaple: file1 and file2 has 1 bit if then exit else send out email fi if then exit else send out email fi it exits the 1st if. did not continue with my 2nd if. thanks in advanced. Please use CODE tags are suggested on every page when you post an item in... (7 Replies)
Discussion started by: lawsongeek
7 Replies

3. Shell Programming and Scripting

Sftp : not able to print the echo statements after the sftp transfer

I had the below sftp script working perfectly but the problem is I am not able to send the echo statements . #!/bin/sh echo "Starting to sftp..." sftp admin@myip << END_SCRIPT cd /remotepath/ lcd /localpath/ mget myfiles*.csv bye END_SCRIPT echo "Sftp successfully." echo echo... (11 Replies)
Discussion started by: scriptscript
11 Replies

4. Shell Programming and Scripting

Echo not displaying variable in If-Else condition

if then echo "Entry Valid : ${x_oug}" else echo "Entry Invalid : " 0 fi In the above code the 3rd line is not working... it does not print anything I tried following as well .. but no luck! echo "Entry Valid : ... (13 Replies)
Discussion started by: Chetanz
13 Replies

5. Shell Programming and Scripting

Multiple while statements?

I'm working on a script for class as a final project. We have to ask for values (city, state, zip) five times, but the state can only be MI, IN, IL, or OH. I'm trying to do this with a while loop inside of a while loop, but I have no idea how to do it properly. Here's what I have so far: ... (3 Replies)
Discussion started by: nickzourdos
3 Replies

6. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

7. Shell Programming and Scripting

Multiple if Statements

Hi All, I need to check for 3 conditions and if all the 3 are not satified need to say that services are not running.... is the below code correct. #********** Check to see if Service 1 is still running************** if then echo "$datetimestamp: Service1 is not running" >>... (4 Replies)
Discussion started by: ch33ry
4 Replies

8. Shell Programming and Scripting

How do I execute multiple statements within If then else

Please help me. I have been doing this for several hours. Here is the code if then echo a b c d >> file.txt echo 1111 >> file.txt fi The reason I want the two echo is because I want these statements printed on multiple lines. I keep getting error . First it tells me... (2 Replies)
Discussion started by: asemota
2 Replies

9. Shell Programming and Scripting

How to write multiple echo statements in unix?

How to write multiple echo statements in unix? echo "************************************************************************************************************"; echo This Script do the following functions echo 1. Point 1 echo 2. Point 2 echo 3. Point 3 echo... (2 Replies)
Discussion started by: Shrutiduggal
2 Replies

10. Shell Programming and Scripting

How to place the output of two different echo statements on one line

Hello there, I wrote a shell script to modify the code for some of our clients in our client database. Before starting the data modification the program performs a few checks. When a check is being performed, it should be shown on the screen of the user running the program, the result of... (5 Replies)
Discussion started by: JoBa
5 Replies
Login or Register to Ask a Question