How to sort file after text-me-not/ in Unix and ignore case?
By Sarah Scott •
I have this data and want to sort it alphabetically after the string test-me-not/ and ignore case.
hello-yourself/www/test-me-not/watermelon-green
hello-yourself/www/test-me-not/orange-orange
hello-yourself/www/test-me-not/apple-red
hello-yourself/www/test-me-not/mango-yellow
hello-yourself/www/test-me-not/Apple-green
hello-yourself/www/test-me-not/Pineapple-yellow
hello-yourself/www/test-me-not/cherry-red
hello-yourself/www/test-me-not/grape-violet
hello-yourself/www/test-me-not/Grape-green 1 2 Answers
I assume that the data is in a file.. (If not edit the question.)
Run in terminal:
cat /path/to/src/file | sed 's:hello-yourself/www/test-me-not/::' | sed '/^$/d' | sort --ignore-casefor output in terminal and
cat /path/to/src/file | sed 's:hello-yourself/www/test-me-not/::' | sed '/^$/d' | sort --ignore-case > /path/to/destination/filefor output in a file.
To merge text files, then sort them line by line using this command on terminal:
cat textfile1.txt textfile2.txt | sort > sortedtextfile.txtYou can watch this video for more context on this process.