I've created a script for account creation that reads from a csv file, i do not need the first line in the csv as it has the titles for the colums, im trying to delete the first line using sed 1d $file, but it doesnt seem to work.
#!/bin/bash
FILE="applicants.csv"
sed 1d $FILE |while IFS=: read USERNAME PASSWORD SCHOOL PROGRAM STATUS; do
#------------------------------------------
groupadd -f $SCHOOL
useradd $USERNAME -p $PASSWORD -g $SCHOOL
if [ $? == 0 ]; then
echo
echo "Success! $USERNAME created"
grep $USERNAME /etc/passwd
echo
#------------------------------------------
else
echo "Failed to create account for $USERNAME"
fi
done < $FILE
here is the csv file
Full Name:DOB:School:Program:Status
JoseDavid:22-08-86:ACE:Bsc Computing:Unfinished
YasinAhmed:22-07-85:ACE:Bsc Networking:Complete
MohammedAli:21-04-84:ACE:Bsc Forensics:Complete
UtahKing:22-09-84:ACE:BSC IT:Unfinished
UsmanNaeem:21-09-75:ACE:BSC Computing:Complete
Here is a screenshot of the output https://i.sstatic.net/R5zPN.jpg
is there anyway to skip the first line?
Try using tail -n +2 $FILE
instead of sed.
You're reading from the unedited file with the redirect at the end: done < $FILE
. Try changing that line to just done
.