One of my uglier scripty bits

So – sed and awk versions on the Mac are a little behind. Turns out if I write an expression to wrap a forward slash into braces that it doesn’t exactly translate when moving from Linux to a Mac. So this happened (make fun, it’s cool):

#!/bin/bash #Extracts occurances of a file path from a text file #Then sorts and counts up each echo "Please make sure to run script from same Original_file PATH" read -p "Enter filename: " original_file cp $original_file tempfile.txt && sed 's/ /\n/g' tempfile.txt > tempfile1.txt && sed -i '.bak' '/^$/d' tempfile1.txt && cat tempfile1.txt | grep '^/' | sort |uniq -c | sort -k2nr |sort -r| awk '{printf("%s,%s\n",$1,$2)}' > filtered-sorted-file.txt && rm -rf tempfile*.txt

The script extracts all file paths from a text file and sorts/counts them. I thought it would take 5 minutes… Famous last words…

This site uses Akismet to reduce spam. Learn how your comment data is processed.