Issue
i have an email address and i am wanting to split the email in the first letter of the firstname and full last name and put them in a place holder. eg: [email protected]
x = f
y = lastname
I did use try firstCharacter=${email:0:1}
to get the first char but am not sure how to get the last name.
Full code here
#!/bin/bash
file="users.csv.1"
Count=0
while IFS=";"; read email birthDate group sharedFolder
do
echo -e "Email: $email"
firstCharacter=${email:0:1}
echo $firstCharacter
IFS="."
read -ra
echo -e "Birth Date: $birthDate"
echo -e "Group: $group"
echo -e "shared Folder: $sharedFolder\n"
done < "$file"
Solution
local_part=${email%%@*} # remove trailing `@*` (glob-style pattern)
last_name=${local_part##*.} # remove the leading `*.` from above
Answered By - Gedge Answer Checked By - David Marino (WPSolving Volunteer)