Script doesn't understand if conditiojn with or


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script doesn't understand if conditiojn with or
# 1  
Old 03-07-2017
Script doesn't understand if conditiojn with or

I Bourne shell I have a lines

Code:
 #!/bin/sh
 something
 for file in *_${Today}*.csv *_${Today}*.txt
 do
  if [ -f "LET_daily_trans_${Today}.csv" ||  -f "LET_daily_trans_345_${Tod
ay}.csv" ]
  then
                echo "This file will be processed in separate script"
                continue
  fi
something
 done

The script doesn't understand if condition. Could you please let me know what is wrong?

Thanks for contribution
# 2  
Old 03-07-2017
Code:
if [ -f "LET_daily_trans_${Today}.csv" ] ||  [ -f "LET_daily_trans_345_${Today}.csv" ]

# 3  
Old 03-07-2017
When I put it this way

Code:
 if [ -f "LET_daily_trans_${Today}.csv" ] ||  [ -f "LET_daily_trans_345_${Today}.csv" ]

if check this condition for all my files, which doesn't have LET in the name
# 4  
Old 03-07-2017
PLEASE get used to the habit of posting DATA, CONTEXT, ERROR messages, etc. so people can understand and/or analyse WHAT goes wrong.

Your statement is difficult to understand and believe. As long as there is a (any) file named LET_daily_trans_${Today}.csv or LET_daily_trans_345_${Today}.csv, with Today having a matching contents, the condition is true irrerspective of any other file name that you might work upon.
# 5  
Old 03-07-2017
Code:
if [ "$file" = "LET_daily_trans_${Today}.csv" ] ||  [ "$file" = "LET_daily_trans_345_${Today}.csv" ]

# 6  
Old 03-08-2017
@Don, the use of double == in a test command is not part of the POSIX standards. rdrtx1's suggestion is grammatically correct.

See test: operands
# 7  
Old 03-08-2017
Quote:
Originally Posted by Scrutinizer
@Don, the use of double == in a test command is not part of the POSIX standards. rdrtx1's suggestion is grammatically correct.

See test: operands
Hi Scrutinizer,
Yes, you are absolutely correct. I have deleted my post with the incorrect suggestion.

Sorry,
Don
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help me understand this script

#!/bin/awk -f BEGIN {i=1;file="modified.txt"} { if ($0 !~ /^DS:/) {print $0 >> file} else { if ($0 ~ /^DS:/) {print "DS: ",i >> file;if (i==8) {i=1} else {i++}}; } } END {gzip file} Can someone explain to me how this above script works, I got it from a friend but not able... (3 Replies)
Discussion started by: Kamesh G
3 Replies

2. Shell Programming and Scripting

Need help to understand the below shell script

Please help me to understand the below 3 lines of code.execute shell in jenkins 1)APP_IP=$( docker inspect --format '{{ .NetworkSettings.Networks.'"$DOCKER_NETWORK_NAME"'.IPAddress }}' ${PROJECT_NAME_KEY}"-CI" ) 2)HOST_WORKSPACE=$(echo ${WORKSPACE} | sed... (1 Reply)
Discussion started by: naresh85
1 Replies

3. Shell Programming and Scripting

Help to understand a script

Hello world! Can someone please explain me how this code works? I'ts supposed to find words in a dictionary and show the anagrams of the words. { part = word2key($1) data = $1 } function word2key(word, a, i, x, result) { x = split(word, a, "") asort(a) ... (1 Reply)
Discussion started by: jose2802
1 Replies

4. Shell Programming and Scripting

Need help to understand this small script

Hi Guys, I need to understand below scipt:- -bash-3.00$ cat rsync-copy.ksh #!/usr/5bin/ksh batch <<%EOF% echo "/usr/local/bin/rsync --rsync-path=/usr/local/bin/rsync -a --stats /usr/openv/ /OpenvBCK" > openv.LOG # CG /usr/local/bin/rsync ... (6 Replies)
Discussion started by: manalisharmabe
6 Replies

5. Shell Programming and Scripting

awk doesn't understand 'read' statement!!!

While working on awk programming, i found that it doesn't understand 'read' statement. Then what's the use of 'continue' and 'break' statement in awk. For ex: awk '{k=1; while (k<10) {print $0; k++}}' emp.lst Now, please say if I want to put the logic that after priting 1 line, it will ask for... (13 Replies)
Discussion started by: ravisingh
13 Replies

6. Red Hat

Grep doesn't understand escape sequence?

I ran the following grep and sed command. grep "\t" emp.txt sed -n '/\t/p' emp.txt grep treated the '\' as to escape t and took the pattern as literal t whereas sed took the pattern as tab. That means , grep doesn't understand escape sequence!!!!!! what to do to make grep... (8 Replies)
Discussion started by: ravisingh
8 Replies

7. Shell Programming and Scripting

Understand script formte

Hi i have one script and i am running it but not getting current output so i want to understand how to input in the script. when i do help then i am getting below massage thanks got it (1 Reply)
Discussion started by: asavaliya
1 Replies

8. Shell Programming and Scripting

Help to understand the script

Hi All; Is there anybody can explain this script please? trap 'C_logmsg "F" "CNTL/c OS signal trapped, Script ${G_SCRIPTNAME] terminated"; exit 1' 2 trap 'C_logmsg "F" "Kill Job Event sent from the Console, Script ${G_SCRIPTNAME] terminated"; exit 1' 15 (3 Replies)
Discussion started by: thankbe
3 Replies

9. Shell Programming and Scripting

Can't understand the script

I am relatively new to Shell Scripting. I can't understand the following two scripts. Can someone please spare a minute to explain? 1) content s of file a are (021) 654-1234 sed 's/(//g;s/)//g;s/ /-/g' a 021-654-1234 2)cut -d: -f1,3,7 /etc/passwd |sort -t: +1n gives error (3 Replies)
Discussion started by: shahdharmit
3 Replies
Login or Register to Ask a Question