← Runnable Projects

阅读中文版本

Bash CSV Column Extract

Bash CSV Column Extract — a runnable bash project with source, install and run commands, and expected output.

intermediatebashunverified

Project

bash-csv-col-extract

Entry point: extract.sh

Install

bash extract.sh data.csv 2

Run

bash extract.sh sample.csv 2

Test

bash extract.sh sample.csv 2

Expected output

Extracts one column from a CSV and prints it line by line.

Dependencies

  • bash >=4
  • awk >=5

Verification evidence

Source reviewed against bash standard library APIs. Commands verified for syntax; execution not yet exercised in CI.

Security note

Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.

What it does

Bash CSV Column Extract is a self-contained bash command-line program. Extracts one column from a CSV and prints it line by line.

Install and run

bash extract.sh data.csv 2
bash extract.sh sample.csv 2

Project structure

bash-csv-col-extract/
├── extract.sh
└── README snippet above

Key source

#!/usr/bin/env bash
set -euo pipefail
awk -F, -v col="$2" '{print $col}' "$1"

Testing

bash extract.sh sample.csv 2

Expected output

When run with the documented command, the program prints:

Alice\nBob\nCarol   (column 2 values)