Skip to main content
100%

Append string on each line to csv file

✓ Published0🌍 Public
Aadkdev
Last edited Sep 24, 2021
Created on Sep 24, 2021

This example demonstrates a shell script that appends the string `"active"` to the end of every line in a CSV file, producing a new output file. It uses the `sed` command with a regular expression to match the end of each line (including lines with or without a trailing carriage return) and replaces it with `,"active"`. The script reads from `file.csv` and writes the modified content to `out.csv`. The transformation relies on POSIX `sed` in extended regex mode, paired with a Bash-specific ANSI-C quoting trick to handle the `\r` character.

AI-generated description

Similar vizzes