bash: URL: 명령을 찾을 수 없습니다.

bash: URL: 명령을 찾을 수 없습니다.

Bash(Windows 사용)에서 계속 다음 오류가 발생합니다.

$ URL = "https://nyc-tlc.s3.amazonaws.com/trip+data/yellow_tripdata_2022-01.parquet"
bash: URL: command not found

Bash에서 실행하려는 전체 명령은 다음과 같습니다.

URL = "https://nyc-tlc.s3.amazonaws.com/trip+data/yellow_tripdata_2022-01.parquet"

python ingest_data.py \
  --user=root \
  --password=root \
  --host=localhost \
  --port=5432 \
  --db=ny_taxi \
  --table_name=yellow_taxi_trips \
  --url=${URL}

전체 명령을 실행하면 ingest_data.py 파일이 실행되지만 다운로드가 발생하지 않습니다(이 오류 때문인 것 같습니다 URL: command not found.

ingest_data.py를 실행하면 아무 일도 일어나지 않습니다. 위의 전체 명령을 실행하는 것과 유사합니다.

ingest_data.py 파일에 사용되는 URL의 "중요" 부분은 다음과 같습니다 os.system(f"wget {url} -0 {flatfile_parquet}").

def main(params):
    user = params.user
    password = params.password
    host = params.host
    port = params.port
    db = params.db
    table_name = params.table_name
    url = params.url
    flatfile_parquet = 'output.parquet'
    
    # download the parquet file
    os.system(f"wget {url} -0 {flatfile_parquet}")
    
    # connect to server
    engine = create_engine(f'postgresql://{user}:{password}@{host}:{port}/{db}')

컬을 사용하라는 스레드를 찾고 있었지만 bash에서 파일을 다운로드하고 싶지 않고 URL을 변수에 저장한 다음 파일에서 사용하고 싶습니다 ingest_data.py.

어떤 제안이라도 감사하겠습니다. 저는 bash에 대해 약간 멍청합니다.

답변1

첫 번째 줄에 구문 오류가 있습니다. "=" 주위에는 공백이 없어야 합니다. 그렇지 않으면 BASH는 첫 번째 단어를 명령으로 실행하려고 시도합니다. 고려하다:

$ a = "xx"
bash: a: command not found
$ echo = "xx"
= xx
$ a="xx"
$ echo "$a"
xx

다음을 사용해야 합니다.

$ URL="https://nyc-tlc.s3.amazonaws.com/trip+data/yellow_tripdata_2022-01.parquet"

관련 정보