LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 01: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 01:45 PM.
 
Old 02-19-2016, 01:58 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 & 7
Posts: 3,025

Rep: Reputation: 806Reputation: 806Reputation: 806Reputation: 806Reputation: 806Reputation: 806Reputation: 806
I don't think "HOWOLD=$(cat $LOGIF | wc -l)" will work in sh. You need to run it in bash.
 
Old 02-19-2016, 02: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 02:26 PM.
 
Old 02-21-2016, 04:50 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,565

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

Rep: Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944
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, 09: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 07:19 PM
[SOLVED] Insert line using sed or awk at line using line number as variable sunilsagar Programming 11 02-03-2012 11:48 AM
extract last number from filename csegau Linux - Newbie 8 05-28-2010 08:24 AM
how to convert address in current process to filename:line number telia Linux - General 5 01-12-2009 05:06 AM
Pass a variable as a line number in sed dx0r515t Programming 7 03-30-2007 05:55 PM

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

All times are GMT -5. The time now is 08:38 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration