There is a text file that has multiple lines as shown below:
djfldfjd:lisa
ldj:roma
dkjdkjflddlsdkjdlkj:kathy
ldadkjfdsldkjdlkfjdlkkkkkkkkkkkkkkkkkkkkl:purple
dkjdljl:christine
kdllkldkjhhhhhhhhhhhhhhh:george
ldkjfdl:kathy
Now all I need is a script to process all the lines of the above text file and compare the string present after colon and get the repeated string after colon and print those strings before colon.
So I tried with below script, but getting error mentioned below:
#!/usr/bin/sh
input="test.txt"
cat $input | while read line; do output= $(echo $line | cut -d":" -f2); done
for (( i = 0 ; i < "${#output[@]}" ; i++ ))
{
echo ${output[i]}
}
Error message:
./compare.sh: line 11: test1: command not found
Any help would be highly appreciated. Thank you.
Error: line 11 not found
Is the error message from this script? Please correct. Post real code and real error messages. – ctrl-alt-delor Jan 24 '21 at 15:52