Hey, I'm new here. Basically, I'm trying to make a bash script that affects a file of my choice.
What I want to do is
$./script.sh /path/to/file.jpg
and then the bash script will know that variable=/path/to/file.jpg
Thanks!
Hey, I'm new here. Basically, I'm trying to make a bash script that affects a file of my choice.
What I want to do is
$./script.sh /path/to/file.jpg
and then the bash script will know that variable=/path/to/file.jpg
Thanks!
In your script.sh:
variable="$1"
Is it what you are looking for?
No, what I'm looking for is a way to import text from the command line when I run the script.
Here is what I'm trying to do.
#! /bin/bash
echo 'Where is the file located?'
read location
COUNT=1
while [ $COUNT -lt 7 ]; do
exif -t 0x000$COUNT --remove $location -o $location
let COUNT=COUNT+1
done
This little script strips out the exif GPS data (so if I upload a picture online, I don't have to worry about someone showing up at my house).
It loops from 0x0001 to 0x0006 and removes them. It then overwrites the file.
The issue is I don't want to have to type out the file names since I can't get autocomplete to work in BASH. So instead of setting the location of the file with:
echo 'Where is the file located?'
read location
I could just use ./script.sh ~/Desktop/file.jpg and script.sh will know that ~/Desktop/file.jpg shall be the location variable.
Replace following two lines
echo 'Where is the file located?'
read location
with
location="$1"
Now when you run script like below:
./script.sh /path/to/your/filename
1st argument ($1) will be set in location variable.
Brilliant! Thank you. I didn't understand what you were saying in your first post. I'm still new to bash scripting, as you can see