user3310704
user3310704

Reputation: 1

Shell script value issue

Here is my script.

#!/bin/sh
grep $ `date +%Y%m%d`/filename.txt | sed 1d

pretty simple. I am looking to be able to run the script with just a value after it, where the value should replace the "$", such as:

bash-4.1$ ./script.sh | "value"

Any ideas on how I can do this?

Upvotes: 0

Views: 37

Answers (1)

Charles Duffy
Charles Duffy

Reputation: 295288

Use $1, and run it as ./yourscript value.

That is to say:

#!/bin/sh
grep -e "$1" "$(date +%Y%m%d)/filename.txt"

...and...

$ ./yourscript "value"

The pipe construct isn't appropriate here -- it's used when you connect the output of one process to the input of another.

See also http://mywiki.wooledge.org/Arguments

Upvotes: 2

Related Questions