How to get result (not return code) from grep into a variable
Hi,
Hopefully you can help me.
I have a text file containing a record for each photo - the line contains md5 tag whitespace and the full path/filename for each photo. I select a folder that I believe contains a lot of dupes and then take the md5 tag for the first item in this and search the entire file so I will get at least one hit (the photo that I am searching with). If I find more than one I want to delete the full path/filename.
I am using grep to count the matches ===>> grep -c "c9b09af7a76c7abe17ce9f15b6da3820" /Users/teba/tasks/photo_work/photo_md5_dir_list.csv |sed -r "s/\s+//g" | awk -F ":" '{print $1,$2}' | sort -nr -k2| head -1
In terminal window it returns a number (in my case 3) however I can't get the result of grep into a variable to test it for greater than 1. (Only to a file)
I was going to write the script with AppleScript - if there is a better way please point it out to me
All of my scripting is done by grabbing ideas/solutions that all of you in the community have published - so thank you to everyone!
Any help would be appreciated.
Terry