Programming :: Bash - Syntax For ((<arithmetic Expression>)) Usage ?
Mar 18, 2010
I do not understand bash' syntax regarding the use of ((<arithmetic expression>)). $((<arithmetic expression>)) is tokenised to a single word. OK.
Code:
In isolation
Code:
It may not be used where a word is expected. This generates a syntax error. Why?
Code:
View 6 Replies
ADVERTISEMENT
Nov 10, 2010
I have four files that contain numbers that I grep for in a variable#!/bin/bashcat FILENAME`date +%y%m%d*.tot` | grep Grand | awk '{print $4}'
#output is
12
67
[code]...
View 6 Replies
View Related
Jun 7, 2011
This line if [[ $hamachi_reachable = true && $lan_reachable = true ]]; then is always evaluating to true. I gave two ips that are not valid, so that both variables would become false yet the whole expression is evaluating as true. With that set -x in there, I get this output.
Where am I going wrong?
Code:
View 11 Replies
View Related
May 15, 2010
My main problem right now is doing floating point arithmetic within a bash script, with variables.Right now I have a folder called "myExamples" with a script called "run_example" that runs with no issues.I plan to(1) create many folders inside [myExamples], that are named [example10] [example11]...each containing an identical copy of (run_example),(2) modify Line 172 of each copy of (run_example)...in one copy, it would be 3.00, the next copy would have 3.05, etc. (This part doesn't work!)How can use the available calculator bc code to do floating point operations?My code is below -
#!/bin/sh
# run from directory where this script is
cd `echo $0 | sed 's/(.*)/.*/1/'` # extract pathname
[code]...
View 2 Replies
View Related
Jan 1, 2011
I am setting some environmental variable in my .bashrc , the sample code I was provided with is for CSH but I am using bash, and there are some syntax differences between them ... I got most of the script to work, but I am getting an error at this part :
Code: if ($RMSTREE == $RMANTREE) then
set path=($path $RMANTREE/bin)
else
[code]...
View 2 Replies
View Related
Dec 26, 2010
I'm new to scripting and I have a trouble with if statement syntax. The code is: Code: #there is a diff command here, and it does what i want but#i wanna see 1 if the exit value of diff is 0, and otherwise i wanna see 0.#the problem is here: (syntax error near unexpected token "then")
if["$?"==0];
then
echo 1
[code].....
View 1 Replies
View Related
Apr 23, 2011
I have this project which I've been working on essentially nonstop for the past three days and due to work I am running low on time. I'm new to Linux/Unix and my Teacher has assigned us a scripting project, due for Monday. I have All the functions for the project in a separate file which run as a daemon process when I log in. It has no syntax errors but my Script can not run the functions (I'm not sure where they go before or after the body) and I have one function I'd like you guys to take a look at. It has a Second menu leading to a case statement but it does not run after the Search. I'm Kinda tired of looking at the CLI but I have to finish this.
phoneEdi() {
directory=~/phonepro/directory
loop="y"
clear
tput cup 4 4; echo "Record Editor" .....
View 1 Replies
View Related
Feb 24, 2011
I have a daemon script which wakes up every 5 minutes and checks the health of started processes. It works fine during the day but throws a syntax error just after midnight.Here is the log:
(02/22-23:49) Check all started processes
(02/22-23:54) Check all started processes
(02/22-23:59) Check all started processes
[code]....
View 9 Replies
View Related
Apr 12, 2010
I have a bash script giving me the following error:
[Code]...
When I run it I am getting: ./svnup: line 61: syntax error: unexpected end of file Can't for the life of me figure out what is wrong. It's a script to export the latest revision from SVN to the web root folder and archive the previous version, basically.
View 4 Replies
View Related
Mar 10, 2011
I've the following input file (sorted.txt)
Code:
A 1
A 1
[code]...
View 6 Replies
View Related
Jul 9, 2010
I was trying to run small shell script, but could not run. I got the error like in subject.
This is exact way i was trying to do.
View 6 Replies
View Related
Apr 20, 2011
I am a Novell (now defunct) CNE tring to learn Linux and am having a lot of trouble finding out where the WB 6-6 is wrong in the syntax for adding local4... the the syslog-ng config file. In the instructions there are discrepancies between commas and simi-comma, they are both in the statements in no particular order. there is no pattern to them. Here is what the book shows:
filter f_local4debug { level(debug) and facility(local4); };
When I try to input this in the Gnome terminal window to try and find out where it goes wrong I get the following: -bash: syntax error near unexpected token "(" If I can get the correct syntax I belive I can use the info to get past the rest of this portion of the lesson. I am desperate to learn Linux as the only jobs out there for a Novell CNE are migrations to MS, which really sucks, since MS really really sucks.
View 1 Replies
View Related
Jan 21, 2011
I want to rename some files in one directory and found the command 'rename' most appropriate.
Changing the file extension is easy since there are lot of examples for this.
But now I want to rename my files like this:
'somePrefix_blablabla.ext' --> '0_blablabla.ext'
'somePrefix_blablablablabla.ext' --> '0_blablablablabla.ext'
I DON'T want an incrementation, just the leading prefix '0_'
correct perl expression syntax for this?
View 2 Replies
View Related
Nov 19, 2010
Is it possible to do arithmetic in shell scripts? If so, just how is it done?Here is the code so far:
Code:
#!/bin/bash
time=$(date +%H%M)
[code]...
View 14 Replies
View Related
Jun 1, 2010
What is the difference between *ptr++ and (*ptr)++. In my opinion the terminology is all over the place so if you could give an example it would be better.
View 8 Replies
View Related
Nov 17, 2010
Quote:
#!/bin/sh
for i in {1..10}
do
for j in {1..50}
[code]....
The first echo generates something like: abc.de.fgh The second echo generates:
View 3 Replies
View Related
Feb 7, 2011
I pride myself on at least trying to help myself before I ask, but I've been staring at this a long time, I'm just not getting any traction.I've literally got 3 linux references on my desk right now that say that I should be able to use if conditionals, for example
[ -d FILE ]True if FILE exists and is a directory.
[ -e FILE ]True if FILE exists.
[ -f FILE ]True if FILE exists and is a regular file.
[code]....
View 7 Replies
View Related
Oct 6, 2010
I want to translate this .fdi clause
Quote:
<match key="info.product" string="PS/2 Generic Mouse">
<merge key="input.x11_options.EmulateWheel" type="string">true</merge>
<merge key="input.x11_options.EmulateWheelButton" type="string">2</merge>[code].....
into its Xorg equivalent. What does it look like?
View 1 Replies
View Related
Feb 17, 2011
In a bash script brought over from a Debian/Lenny system, Ubuntu 10.04 stumbles on the left parenthesis in the expression below:NEED_COLS=$[($HEX_WIDTH * 4) + 12]Is it an Ubuntu/Debian script style mismatch, or just post-Lenny? If that can be answered, is there a way to reconcile or syntax check older scripts?
View 2 Replies
View Related
Apr 12, 2011
I'm scratching my head over a very simple netcat-based heartbeat monitoring script i wrote.
here we go:
Code:
echo `date --utc "+%Y-%m-%d %H:%M:%SZ"` script started
[code]...
View 6 Replies
View Related
May 2, 2010
I am trying to install vlc media player on my backtrack3 but when i am giving a command xvjf to extract bz2 file then
bash: syntax error near unexpected token `('
View 1 Replies
View Related
Sep 10, 2009
I'm starting to learn bash scripting and I can't figure out what's wrong with the following.
Code:
#!/bin/bash -x
ALFA=`kdesu "kdialog --getexistingdirectory ."`
echo $ALFA
View 9 Replies
View Related
Nov 30, 2010
I've found the following script to copy files specified by a find output into a target directory.Code:find $SOURCE -name "*.avi" | xargs -i cp -v {} $TARGETWhat exactly does the colored expression mean? Does it refer to an array?
View 3 Replies
View Related
Sep 9, 2010
I've been trying to find a bug in this test script, but haven't been able to so far. I'm not lazy, I promise...just new to Bash so am having a hard time catching syntax errors. I call the script with the option -disableVenusBld, and it still prints "Starting build", which it shouldn't be doing right?
[Code]...
View 1 Replies
View Related
Apr 25, 2011
I know it's possible to change the $ user@hostname colors, but is it possible to color different things? Could I make all numbers/integers a certain color. Or set certain keywords to be bold?
View 1 Replies
View Related
Apr 28, 2011
I'm trying to be able to Open a text editor without needing an existing file.This is my code:
case $ans in
"Show Today") echo "$(date)";;
"Show Calendar") cal;;
[code]...
View 14 Replies
View Related
Apr 21, 2009
I'm trying to code the following WHILE loop in Bash:
While [string1 is non zero] and [string2 is non zero] and [counter < max]
Do
...
Done
I can't get the syntax right. I've tried:
Code:
while [ -n "$STRING1"] -a [ -n "$STRING2"] -a [$COUNTER -lt $MAX ]
But I get 'Too may arguments'
View 4 Replies
View Related
Sep 2, 2010
I am trying myself on regular expressions. A read on [URL]/regex.htm) that {x} means search X times preceding character. So, why is this :
Code:
wstation~> echo '123456789' | grep [0-9][0-9][0-9]
123456789 # MATCH !! I have 3 numbers in a row.
[code]...
View 2 Replies
View Related
May 7, 2011
I've spent most of the evening browsing the web, trying many things I've found on various forums, but nothing seems to work.
I have a test.txt file containing many lines like the following ones :
...
<insert_random_text>228.00 €<insert_more_random_text>
<insert_random_text>17.50 €<insert_more_random_text>
<insert_random_text>1238.13 €<insert_more_random_text>
...
And I want to extract :
...
228.00
17.50
1238.13
...
There is always one occurrence of € in each line. I want the numeric value that precedes this € occurrence. The random text (before and after) may contain numbers too, so the € may be important to parse, in order to correctly identify the number to return. The last character that precedes the number to extract is always a ">" (coming from an HTML tag).
View 9 Replies
View Related
Jan 2, 2010
I'm working with javascript and trying to replace all instances of a Roman character in a string with nothing. How do I assign var reg to all Roman characters? In UTF8, capital letter A is U0041 and at the other end, small z is UFF5A.
So, I'd like to do something like:
var reg = u0041 - UFF5A;
str1 = str.replace(reg, '');
I think you get the idea. I have no idea if that can be done. The idea is to take this string (for example): str = make a door-to-door[house-to-house] visit / ring every doorbell." And take out all the Roman characters and define it as str1. And then take out all the Korean characters (u1100-uFFDC) and define it as str2. In fact, a WAY more useful thing to do would be to replace the instance of this: [u1100-uFFDC]+" "+[u0041-UFF5A] with [u1100-uFFDC]+","+[u0041-UFF5A] so that the output would be a .csv file.
View 5 Replies
View Related