0

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
    Since the prefix hello-yourself/www/test-me-not/ is lexically identical in every case, it shouldn't matter whether you include or exclude it from the sort key – steeldriver Apr 25 '19 at 18:41
0

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.

0

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.