Fast news: @MX_Linux

The Forum is now on mxlinux.org and uses an encrypted (https) connection

  • antiX-16, release info here -- watch the video. Torrents here
  • MX-15 (antiX MX), release info here: here. Monthly update/upgrade available here.
  • Older MX Linux releases available on the download page

New users
  • Please read this first, and don't forget to add system and hardware information to posts!

Shell Script Question [OR]

Here is where users who have been using MEPIS awhile and know the basics of linux and MEPIS can ask questions.
User avatar
Forum Regular
Forum Regular
Posts: 246
Age: 2015
Joined: Thu Jul 13, 2006 6:35 pm

Shell Script Question [OR]

#1 Postby outlaw » Tue Mar 06, 2012 1:57 pm

The following code executes correctly:

# Remove old recording before recording new
if [ -f "$HOME/CBC-Radio/World-Report/incomplete/world-rpt" ]; then
if [ -e "$HOME/CBC-Radio/World-Report/$DATE.mp3" ]; then
rm $HOME/CBC-Radio/World-Report/*.mp3

Yet when I add the OR logical operator the code fails.

# Remove old recording before recording new
if [[ -f "$HOME/CBC-Radio/World-Report/incomplete/world-rpt" ] -o [ -f "$HOME/CBC-Radio/World-Report/incomplete/world-at-6"]]; then
if [ -e "$HOME/CBC-Radio/World-Report/$DATE.mp3" ]; then
rm $HOME/CBC-Radio/World-Report/*.mp3

./tmp.sh: line 13: syntax error in conditional expression
./tmp.sh: line 13: syntax error near `]'
./tmp.sh: line 13: `if [[ -f "$HOME/CBC-Radio/World-Report/incomplete/world-rpt" ] -o [ -f "$HOME/CBC-Radio/World-Report/incomplete/world-at-6"]]; then'

I can't find the syntax error, perhaps someone with more experience or younger eyes could point out the error of my ways ...

Thanks in advance for any advice or suggestions offered.


Never eat more than you can lift." --Miss Piggy

User avatar
Posts: 13270
Joined: Wed Jul 12, 2006 2:17 pm

Re: Shell Script Question [OR]

#2 Postby richb » Tue Mar 06, 2012 2:06 pm

Looks like you need to remove two brackets.


Code: Select all

or (logical)

if [ $condition1 ] || [ $condition2 ]
# Same as:  if [ $condition1 -o $condition2 ]
# Returns true if either condition1 or condition2 holds true...

if [[ $condition1 || $condition2 ]]    # Also works.
# Note that || operator not permitted within [ ... ] construct.

EDIT: I am not a shell script expert, I just Googled the man page for bash shell scripts.
Forum Rules
Guide - How to Ask for Help


Laptop: Acer V5-572G: Intel i5, 12 GIG mem, Intel graphics, SanDisk SSD, 256GB
Virtualbox: Win 7
Desktop: MX-15- 64, AMD A8 7600 FM2+ CPU R7 Graphics, fglrx driver, 16 GIG Mem. Samsung EVO SSD 250 GB

User avatar
Forum Regular
Forum Regular
Posts: 573
Joined: Sun Dec 09, 2007 4:19 am

Re: Shell Script Question [OR]

#3 Postby moksha » Sun Mar 11, 2012 12:02 am

I thought it might be the semi colon after the double brackets

Return to “Regulars”

Who is online

Users browsing this forum: No registered users and 5 guests