How to get the output from [ -s "abc.txt" ]


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get the output from [ -s "abc.txt" ]
# 1  
Old 07-10-2007
Question How to get the output from [ -s "abc.txt" ]

Hi,

I am trying to check the file not empty, if its not empty then i try to send other system by ftp, the following codes doesnt work

if [[ -s "${OUTBOUNDFILE}" ]]
then
echo "File ${OUTBOUNDFILE} have data"
ftp -i -n -v 204.104.22.33 >> ${FTP_LOGFILE} << EOF
user abc def
ascii
put ${OUTBOUNDFILE}
quit
EOF
else
echo "File ${OUTBOUNDFILE} is empty...ftp stopped"
fi

please give ur idea

Thanks in Advance
Imran
# 2  
Old 07-10-2007
Try:

Code:
if ! [[ -s "${OUTBOUNDFILE}" ]]

instead of:

Code:
if [[ -s "${OUTBOUNDFILE}" ]]

The -s option gives true if the file is not zero size.

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

[Python] replicating "sha256 -C checksum_file.txt file.txt"

Hello everyone, Since my python knowledge is limimted, I've challenged myself to learn as much as possible to help me with my carrere. I'm currently trying to convert a shell script to python, just to give myself a task. There is one section of the script that I'm having issues converting and... (2 Replies)
Discussion started by: da1
2 Replies

2. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

3. Shell Programming and Scripting

"Join" or "Merge" more than 2 files into single output based on common key (column)

Hi All, I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations: 1. I am restrained to 2 input files only. 2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Discussion started by: Katabatic
1 Replies

4. UNIX for Dummies Questions & Answers

Explanation of "total" field in "ls -l" command output

When I do a listing in one particular directory (ls -al) I get: total 43456 drwxrwxrwx 2 root root 4096 drwxrwxrwx 3 root root 4096 -rwxrwxr-x 1 nobody nobody 3701594 -rwxrwxr-x 1 nobody nobody 3108510 -rwxrwxr-x 1 nobody nobody 3070580 -rwxrwxr-x 1 nobody nobody 3099733 -rwxrwxr-x 1... (1 Reply)
Discussion started by: proactiveaditya
1 Replies

5. Shell Programming and Scripting

How can I use if statement to check a string start with "abc"

I am trying to write a if statement in KSH that if a string is start with abc then print something, I have written some code as below but it doesn't work. Could someone please help me if ] then print success fi (5 Replies)
Discussion started by: yhever
5 Replies

6. Shell Programming and Scripting

In ksh shell command - Print "-ABC" is giving error

Hi Guys, while executing the following command : print "-ABC" is giving following error : ksh: print: bad option(s) I cannot use echo for some other reasons, so any other option ? (2 Replies)
Discussion started by: sagarjani
2 Replies

7. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies

8. Shell Programming and Scripting

how to make ABC into "ABC" ina file

suppose u have a file ABC CDF ADF FDG HAA AHH AHA so output shud be like "ABC" "CDF" "ADF" FDG " "HAA" "AHH" "AHA" (8 Replies)
Discussion started by: cdfd123
8 Replies

9. Debian

Debian: doubt in "top" %CPU and "sar" output

Hi All, I am running my application on a dual cpu debian linux 3.0 (2.4.19 kernel). For my application: <sar -U ALL> CPU %user %nice %system %idle ... 10:58:04 0 153.10 0.00 38.76 0.00 10:58:04 1 3.88 0.00 4.26 ... (0 Replies)
Discussion started by: jaduks
0 Replies

10. Shell Programming and Scripting

Sorting problem "sort -k 16,29 sample.txt > output.txt"

Hi all, Iam trying to sort the contents of the file based on the position of the file. Example: $cat sample.txt 0101020060731 ## Header record 1c1 Berger Awc ANP20070201301 4000.50 1c2 Bose W G ANP20070201609 6000.70 1c2 Andy CK ANP20070201230 28000.00... (3 Replies)
Discussion started by: ganapati
3 Replies
Login or Register to Ask a Question