Linked Questions

94 votes
5 answers
154k views

In my .bashrc, I have a function called hello: function hello() { echo "Hello, $1!" } I want to be able to invoke hello() from the shell as follows: $ hello Lloyd And get the output: > Hello, ...
les2's user avatar
  • 14.5k
48 votes
6 answers
302k views

I'm a newbie to shell scripts so I have a question. What Im doing wrong in this code? #!/bin/bash echo " Write in your age: " read age if [ "$age" -le "7"] -o [ "$age" -ge " 65" ] then echo " You can ...
user2904832's user avatar
13 votes
1 answer
44k views

I am trying to get the array in the while-loop and need to update the value in array too. Below is my code what I have tried. I get this error [0: command not found #!/bin/bash i=0 while [$i -le "{#...
Dhaval Babu's user avatar
10 votes
1 answer
4k views

As a beginner, I did not find answered anywhere, the rules about spacing (grammar) and parsing. For example. Can I do if [$# -eq 2] ; then llll fi or must I always have a blank or two ...
Leslie Satenstein's user avatar
0 votes
6 answers
5k views

I wrote a function in bash script. However, it's complaining about syntax. I really can't see what is it..... the error message is [: missing `]' addem() { if [ $# -eq 0] || [ $# -gt 2 ] ...
Progress Programmer's user avatar
2 votes
2 answers
16k views

I have problem and cant still handle with it. :( Here is my code declare -i disk_usage_rate=$(df -h /appdata/SCT_CDR | cut -d '%' -f 1 | awk 'NR==2{print $5}') while ["$disk_usage_rate" -gt 80] do ....
Süleyman Orhan's user avatar
5 votes
2 answers
5k views

i'm having trouble fixing the error in this bash script, I seriously have no idea what I did wrong, any help is appreciated thanks [centoslive@livecd ~]$ sh ListFich.sh test Synthese, Question 2 ...
Joe E's user avatar
  • 85
-4 votes
2 answers
10k views

I would like to compare the line counts of two separate files. While I have tried using wc -l in the comparison, I'm struggling to get it working properly. I have: if [ "$(wc -l file1.txt)" == "$(wc ...
DomainsFeatured's user avatar
2 votes
1 answer
12k views

I'm having an issue with a script that I am trying to program. Narrowed down and simplified code and it gives an error that command is not found. If i do "test -f file" in command line it returns ...
Sean Sullivan's user avatar
2 votes
1 answer
21k views

I'm trying to write a bash script that imports all users and for each account execute some action. a="some account" b="some account" #... so on USERS = #get imported for ACCOUNT in $USERS; do ...
viviboox3's user avatar
  • 329
3 votes
1 answer
11k views

I am trying to run simple code block. It gives error on fourth line as "syntax error near `$1'" =~ means Matches Regular Expression How should I use '$1' variable with this operator? Here is my ...
Barkan Can Erdogdu's user avatar
3 votes
2 answers
7k views

I have a section of code in a bash shell script that looks like this, with a series of consecutive conditionals: #do January first, no matter what awk '$4 == "Jan" {print $0}' < last-output.txt | ...
Connor's user avatar
  • 43
1 vote
2 answers
10k views

I created a script that helps administrators add and remove users from text file instead of doing it manually. I ran into this error and i'm having trouble solving it. [ec2-user@ip-172-31-15-55 ~]$ ./...
Jone Jamson's user avatar
1 vote
1 answer
6k views

i have written code to count the number of files and directories, but im struggling to make it exit if no argument is given. here is what i have right now, with the first is statement being the ...
Grant Clark's user avatar
0 votes
2 answers
11k views

I have an exe which takes 2 parameters both are csv as below splitline.exe /dir/file1.csv /dir1/file2.csv, this basically splits the lines in the input file to 2 lines in the output file.So,I wrote a ...
Raghav manchale's user avatar

15 30 50 per page
1
2 3 4 5
14