Skip to content

Instantly share code, notes, and snippets.

@GiovanniBalestrieri
Last active April 13, 2016 14:03
Show Gist options
  • Save GiovanniBalestrieri/030eb87f8972e59859fbc3b05404414d to your computer and use it in GitHub Desktop.
Save GiovanniBalestrieri/030eb87f8972e59859fbc3b05404414d to your computer and use it in GitHub Desktop.
[Bash] Append labels to file. Appends ,yes to positive and ,no to negative
#!/bin/bash
# Path variables
csvPath="/tmp"
echo Please, enter the initial portion of the filename you want to modify
read filename
echo The following file will be modified:
file=$(ls -t $csvPath | grep -v NEG | grep TEST_POS_$filename | head -1)
echo "Labelled file: ${file}"
sed "s/$/,yes/" -i $csvPath/${file}
fileNo=$(ls -t $csvPath | grep TEST_NEG_$filename | head -1)
echo "Unlabelled file: ${fileNo}"
sed "s/$/,no/" -i $csvPath/${fileNo}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment