I am trying to extract the second line of information from a csv file that has the following format:
1234,//data/sub-1234/ses-Baseline
1235,//data/sub-1235/ses-followup
1236,//data/sub-1234/ses-01
1235,//data/sub-1235/ses-02
I have the following script that should work, and it prints out the correct paths when asked. However, it always prints out "Path not found", which points to a problem with the csv file.
#!/bin/bash
csv_file="input.csv"
# Skip the first line
sed '1d' "$csv_file" | while IFS=, read -r col1 col2 rest; do
if [[ ! -e "$col2" ]]; then
echo "Path not found: $col2"
fi
done
where the output for a file that exists is still:
Path not found: //data/sub-1235/ses-02
Thanks so much.