Sponsored Content
Operating Systems Linux Red Hat Script creates additional file Post 303000813 by rbatte1 on Thursday 20th of July 2017 06:41:57 AM
Old 07-20-2017
You haven't said what shell you are using. If this is ksh or plain sh, then the test you are performing in your if statement is still not valid. The double [ and ] suggested are bash. You are saying something like "If the value of $DAY is not null (always true for your code) create or replace the file 15"

You have a redirector, > where you need an expression. Have a look at the manual page for test to see them all. I think you need:-
Code:
if [ $DAY -gt 15 ];then

I have removed the quotes from $DAY so it is not necessarily a string to do a numeric comparison, but the issue now is that if $DAY is null or unset, the if statement is again invalid, so you need to be certain it is set to something.


I hope that this helps,
Robin
This User Gave Thanks to rbatte1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed in script creates output file ending with '?' (^M)

Hi, I'm trying to use sed within a shell script (bash, running ubuntu). The command works fine from the command line, but when I use it within the script, rather than creating a file with the name I've specified, it creates one that ends with a question mark '?' when you use ls, e.g.... (3 Replies)
Discussion started by: jennykay
3 Replies

2. Shell Programming and Scripting

awk script creates empty line

I have the following awk script to which I pass the file > 10 0 0 10 0 0 > 12.997 0 5.71132 12.9098 0.0687626 5.48855 12.7506 0.174324 5.13225 12.5913 0.262662 4.80643 12.4316 0.335652 4.50283 12.2717 0.394598 4.21542 12.1113 0.440399 3.93957 11.9506 0.473646 3.67148 11.7894... (2 Replies)
Discussion started by: kristinu
2 Replies

3. Shell Programming and Scripting

Script sometimes creates an empty file

I have a script that runs ditto for me, and occasionally (if I exit the script while ditto is running in the background) it will leave an empty file named 0 in the script's directory. The next time I run the script, it generates incorrect data because of this file. I know I can easily insert a... (1 Reply)
Discussion started by: reid
1 Replies

4. Shell Programming and Scripting

Script sometimes creates an empty file

I have a script that runs ditto for me, and occasionally (if I exit the script while ditto is running in the background) it will leave an empty file named 0 in the script's directory. The next time I run the script, it generates incorrect data because of this file. I know I can easily insert a... (1 Reply)
Discussion started by: reid
1 Replies

5. Shell Programming and Scripting

Script that creates directory structure

Hi All, I have a script that does daily checks on my storage environment and is run from an AIX host. The script currently works great but I have been changing and updating bits of it to make it easier for my lesser colleagues to understand :p However now with the updates I have made I... (1 Reply)
Discussion started by: colinwilson1303
1 Replies

6. Shell Programming and Scripting

Extraction of .tar.gz creates additional unwanted directories

I'm working on a project that requires me to compress then relocate directories to a different location based on their last date of modification. After running the script I check to see if it worked, and upon unzipping the tar.gz using I created everything that should be there is. I then performed... (4 Replies)
Discussion started by: jrymer
4 Replies

7. Shell Programming and Scripting

Lock file creates with '?'

Hi, I am trying to create a lock file with the following code but for some reason after file is created it has wrong name "PASP?.lock??" Please let us know how to get rid of these '??' from file name and from where they are coming? #!/bin/ksh... (6 Replies)
Discussion started by: sandy162
6 Replies

8. Shell Programming and Scripting

Writing a script that creates a 1GB file with zeros using dd

I am new to Linux. Using latest version of Ubuntu. I want to make a script that creates a 1GB file filled with zeros using dd and then formats the file as vfat with a label of "MYFILE". If anyone can help me it would be appreciated. (9 Replies)
Discussion started by: paviter619
9 Replies

9. Shell Programming and Scripting

In the script I get additional file, which I don't expect do get

I have the following script #!/bin/sh Usage () { echo "Usage: $0 <config_file>" echo "Example: ./sftp_ondemand_daily.sh /export/data/mbsesb/config/ond emand.cfg /export/data/mbsesb/config/filename.lst" exit 1 } if then Usage fi ... (6 Replies)
Discussion started by: digioleg54
6 Replies

10. Shell Programming and Scripting

Writing a script that creates a 1GB file with zeros using dd

I am new to Linux. Using latest version of Ubuntu. I want to make a script that creates a 1GB file filled with zeros using dd and then formats the file as vfat with a label of "MYFILE". If anyone can help me it would be appreciated. (1 Reply)
Discussion started by: amandasaza08
1 Replies
TEST(1) 						      General Commands Manual							   TEST(1)

NAME
test - set status according to condition SYNOPSIS
test expr DESCRIPTION
Test evaluates the expression expr. If the value is true the exit status is null; otherwise the exit status is non-null. If there are no arguments the exit status is non-null. The following primitives are used to construct expr. -r file True if the file exists (is accessible) and is readable. -w file True if the file exists and is writable. -x file True if the file exists and has execute permission. -e file True if the file exists. -f file True if the file exists and is a plain file. -d file True if the file exists and is a directory. -s file True if the file exists and has a size greater than zero. -t fildes True if the open file whose file descriptor number is fildes (1 by default) is the same file as /dev/cons. s1 = s2 True if the strings s1 and s2 are identical. s1 != s2 True if the strings s1 and s2 are not identical. s1 True if s1 is not the null string. (Deprecated.) -n s1 True if the length of string s1 is non-zero. -z s1 True if the length of string s1 is zero. n1 -eq n2 True if the integers n1 and n2 are arithmetically equal. Any of the comparisons -ne, -gt, -ge, -lt, or -le may be used in place of -eq. The (nonstandard) construct -l string, meaning the length of string, may be used in place of an integer. These primaries may be combined with the following operators: ! unary negation operator -o binary or operator -a binary and operator; higher precedence than -o ( expr ) parentheses for grouping. The primitives -b, -u, -g, and -s return false; they are recognized for compatibility with POSIX. Notice that all the operators and flags are separate arguments to test. Notice also that parentheses and equal signs are meaningful to rc and must be enclosed in quotes. EXAMPLES
Test is a dubious way to check for specific character strings: it uses a process to do what an rc(1) match or switch statement can do. The first example is not only inefficient but wrong, because test understands the purported string "-c" as an option. if (test $1 '=' "-c") echo OK # wrong! A better way is if (~ $1 -c) echo OK Test whether is in the current directory. test -f abc -o -d abc SOURCE
/sys/src/cmd/test.c SEE ALSO
rc(1) TEST(1)
All times are GMT -4. The time now is 12:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy