Skip to main content

All Questions

Tagged with
0 votes
2 answers
561 views

bash script: passing arguments to mkfs

I'm writing a bash script to format my partitions. One of the commands I want to run is the following: mkfs.btrfs -f -m single -L root /dev/sda1 So I have split that command into the options part: -...
coverflower's user avatar
0 votes
1 answer
151 views

Passing different set of arguments to the different commands in a linux bash script

I am writing a bash script foo.sh that runs too commands bar with first input argument, and baz with the second argument: #! /bin/bash bar "$1" baz "$2" Now I want to make foo.sh more flexible, ...
Ali's user avatar
  • 451
1 vote
1 answer
741 views

How woulld I add $OPTARGs from one arg to an array

So I'm trying to add values from an optarg to an array. I've got: arrays=() while getopts a: args; do case $args in a) arrays+=$OPTARG;; esac done echo $arrays[@] When I run the script, ./...
Harry's user avatar
  • 11
0 votes
2 answers
7k views

Why does my Bash script display the "too many arguments" error at the cp command?

Here is my script, I get the error "line 33: [: too many arguments", I'm confused why, surely only 2 arguments are being provided to cp here? I am providing two directories to the script with no ...
Mike's user avatar
  • 1,487
3 votes
1 answer
3k views

how to put my arguments into a Bash alias command?

i usually have the following simple alias in my bashrc: alias g="grep --color=always --exclude-dir=\*.svn\*" but now i have to work on systems that only have GNU grep 2.5, hence no --exclude-dir ...
gcb's user avatar
  • 5,021
72 votes
9 answers
122k views

Can I use pipe output as a shell script argument?

Suppose I have a bash shell script called Myscript.sh that need one argument as input. But I want the content of the text file called text.txt to be that argument. I have tried this but it does not ...
Narin's user avatar
  • 823
0 votes
1 answer
2k views

Opening and passing arguments to an application using a shell script on a Mac

I am trying to write a shell script on a Mac which opens RIATest and passes it parameters. My code is: #!/bin/bash echo THIS TEST!!! open -a '/Applications/RIATest 4/RIATest.app' --args /b /r /e 5 ...
Kevin Doherty's user avatar
7 votes
1 answer
10k views

How to preserve white space in Bash arguments

I use the command: cm1 cm2 arg1 arg2 'argument 3' It first goes to cm1, which will then redirect arg1 arg2 'argument 3' to another file. /usr/bin/cm1: #! /bin/bash # some script here shift cm2 $@ ...
François ッ Vespa ت's user avatar
0 votes
1 answer
3k views

Writing this Bash Script to accept Arguments?

How would I go about converting this bash script: mkdir /store/sftp/%USERNAME% sudo useradd -d /incoming %USERNAME% sudo passwd %USERNAME% ## Password needs to be typed or passed in here sudo ...
Urda's user avatar
  • 848