using bash (sed/awk) to extract rows AND columns in CSV files? using bash (sed/awk) to extract rows AND columns in CSV files? bash bash

using bash (sed/awk) to extract rows AND columns in CSV files?


awk -F, 'NR > 1 { print $3 "," $4 "," $5 }' 

NR is the current line number, while $3, $4 and $5 are the fields separated by the string given to -F


Try this:

tail -n+2 file.csv | cut --delimiter=, -f3-5


Bash solutions;

Using IFS

#!/bin/bashwhile IFS=',' read -r rank name school major year; do    echo -e "Rank\t: $rank\nName\t: $name\nSchool\t: $school\nMajor\t: $major\nYear\t: $year\n"done < file.csvIFS=$' \t\n'

Using String Manipulation and Arrays

#!/bin/bashdeclare -a arrwhile read -r line; do    arr=(${line//,/ })    printf "Rank\t: %s\nName\t: %s\nSchool\t: %s\nMajor\t: %s\nYear\t: %s\n" ${arr[@]}done < file.csv