M HYPE SPLASH
// news

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-case

for 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/file

for 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.txt

You can watch this video for more context on this process.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy