I am trying to run the factorial script but it’s not working.
The code is mentioned below:
------------------------------------------------------------------
------------------------------------------------------------------ Execution:
------------------------------------------------------------------
Can anyone please help?
Regards,
GC
Moderator's Comments:
Please use code tags for listings and program output.
---------- Post updated at 09:33 PM ---------- Previous update was at 06:32 PM ----------
Ok, I've got the reason; it's the bash shell version. I was running the script in an old bash version. I found a link where this was stated. It was mentioned that 'seq' command can be used instead but even that is not recognized on my bash.
seq is not a bash feature, but an external command. Apparently, your system does not have it. Perhaps you can try jot. Alternatively, you can use a while loop:
Regards,
Alister
@DeCoTwc: I tried your method but those braces also did not work. I got a similar error message. Looks like the bash I am trying on is too old to understand even your suggested syntax.
I tried the same code on newer bash and it worked fine. Anyways, thanks for your input.
@alister: Your method was working fine. Thank You!
I also tried awk; it also works fine on my old bash version.
Hello all,
I would like to unzip some files with a for-loop.
Is there anyone who could tell me how I should do this - in a correct way?
for file in $(ls); do echo gzip -d < $file | tar xf -; done
The problem is the pipe - I believe. But how could I do it? I need it for the command... (4 Replies)
Hi all,
While doing some checks I found a kind of interesting arithmetic factorial chart with sed, sharing this may be simple but thought to share,
# n=20;for i in `seq $n`;do printf "`seq $i|xargs|sed 's/ /*/g'`= ";echo "`seq $i|xargs|sed 's/ /*/g'`"| bc;done
1= 1
1*2= 2
1*2*3= 6... (6 Replies)
Hi all
Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends.
As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
It is happening with my sessions already second time: a 'for'-loop for some reason stop to work as expected.
That means or it is looping without exitting, or it is not loop even once.
Here example of my try when it is not processing even one loop.
You can see, I start new subshell and... (14 Replies)
i have this code for a simple if loop:
#!/bin/bash
array="1 2 3 4 5"
array2="5 6 7 8 9"
if } -gt ${array} ]; then
echo "${array2} is greater than ${array}!!"
fi
the error is
./script8: line 9: [: too many arguments
./script8: line 9: [: too many arguments
./script8: line 9: [:... (10 Replies)
Hi,
I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh).
The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
The following piece of code is not running because it is fails to go inside the if condition. i want to create a directory if there is no directory in the input path. i am using Linux, by CENT. Please help.
echo " Enter the path where you u want to extract the tar"
read EXTRACT_PATH
ls -ld... (12 Replies)
If then else segment of below code is not working. For each filename code is displaying output for if part as well as else part. Please help its urgent.
for usercusttop in `echo ${filename}|sort|uniq|cut -c 1-${actualwordcount}`
do
... (2 Replies)