0

I have a chained command that is

cd ~/datafetch && rm *.csv && python scrape.py 2 && dedupe

which I want to alias to a command named scrape

The python scrape.py command takes any number, in this case 2 and passes it to my python script in the following line:

num_of_days = sys.argv[1]

I want to be able to run my alias with the argvalue. By that I mean I just want to run

scrape 2

so it passes the 2 to the python scrape.py command to achieve the same thing as the chained command

EDIT

Since someone decided to close this without a comment, I have since tried to write the following bash script as the user who closed the question suggested, and I still get an error when I try to run source ~/.bash_aliases

This is what I added to my .bash_aliases:

scrape() {
    cd ~/datafetch
    rm *.csv
    python3 scrape.py "$1"
    dedupe
}

and this is the error I get when I run source ~/bash_aliases

Traceback (most recent call last):
  File "scrape.py", line 430, in <module>
    backtrack = sys.argv[1]
IndexError: list index out of range
Tendekai Muchenje
  • 440
  • 1
  • 6
  • 20

0 Answers0