LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-19-2016, 12:31 PM   #1
JoseKreif
Member
 
Registered: Jul 2015
Location: Iowa
Distribution: CentOS 6.6, RHEL Server release 5.5 (Tikanga)
Posts: 58

Rep: Reputation: 0
FILENAME.sh: line NUMBER: VARIABLE: not found


This is driving me insane. I think it has to do with Synology

This is being ran on a Synology Server.
Code:
### VARIABLES ###
LOGIF=/volume7/homes/admin/scripts/data/achclean-logi.txt
HOWOLD=$(cat $LOGIF | wc -l)
# END DEFINITIONS


if (( ${HOWOLD} >= 7 )); then
  echo -e "WORKS" >> 
fi
I get this error in the terminal: scriptname: line Number: [Value of HOWOLD]: not found
If I run this on Linux, RedHat, it works.

Code:
HOWOLD=$(cat dfile | wc -l)

if (( ${HOWOLD} >= 2 )); then
   echo "WORKS"
fi

EDIT:
NO LUCK!!!!!!!!

Code:
if [ "$HOWOLD" >= "7" ]; then # if 7, then it's been 7 days!
sh: 7: unknown operand

NO LUCK!!!!!!!!

Code:
if (( "$HOWOLD" >= "7" )); then # if 7, then it's been 7 days!
scriptname: line Number: [Value of HOWOLD]: not found

Last edited by JoseKreif; 02-19-2016 at 12:45 PM.
 
Old 02-19-2016, 12:58 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
I don't think "HOWOLD=$(cat $LOGIF | wc -l)" will work in sh. You need to run it in bash.
 
Old 02-19-2016, 01:09 PM   #3
JoseKreif
Member
 
Registered: Jul 2015
Location: Iowa
Distribution: CentOS 6.6, RHEL Server release 5.5 (Tikanga)
Posts: 58

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by smallpond View Post
I don't think "HOWOLD=$(cat $LOGIF | wc -l)" will work in sh. You need to run it in bash.
I dont have bash. But it seems to work since I am using it in other scripts on this synology.


I'm thinking it's because whatever version of Shell this Synology is using is older then I am use to.

I got it working by using -ge inplace of >=

if [ ${HOWOLD} -ge 7 ];


I love shell scripting, but man it can be painful at times

Last edited by JoseKreif; 02-19-2016 at 01:26 PM.
 
Old 02-21-2016, 03:50 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Within square brackets [[ ]], the operators differ for strings vs numerics http://www.tldp.org/LDP/abs/html/comparison-ops.html
 
Old 02-21-2016, 05:34 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
In future, it would probably help if you tell us exactly what shell you are running so we may assist better.
 
Old 02-22-2016, 08:05 AM   #6
JoseKreif
Member
 
Registered: Jul 2015
Location: Iowa
Distribution: CentOS 6.6, RHEL Server release 5.5 (Tikanga)
Posts: 58

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by grail View Post
In future, it would probably help if you tell us exactly what shell you are running so we may assist better.
Thanks. Looks like the Synology is using Ash "/bin/ash"

I'll keep that in mind for the future
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] i want to pass a line number variable in sed figure20012 Linux - Newbie 3 08-31-2012 06:19 PM
[SOLVED] Insert line using sed or awk at line using line number as variable sunilsagar Programming 11 02-03-2012 10:48 AM
extract last number from filename csegau Linux - Newbie 8 05-28-2010 07:24 AM
how to convert address in current process to filename:line number telia Linux - General 5 01-12-2009 04:06 AM
Pass a variable as a line number in sed dx0r515t Programming 7 03-30-2007 04:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration