 <p>This will sort based on dynamic last field which is separated by <code>/</code>. First it will append last field to the start of the line and then <code>sort</code>. First field which is appended earlier is removed by second <code>awk</code>. </p> <pre><code>awk -F'/' '{ $0= $NF " " $0;print $0 |"sort -k1"}' fil |awk '{print $2}' /Volumes/Location/Workers/Bill/2016-03-17_Bill_PC/DOCS/1998816.doc /Volumes/Location/Workers/Andrew/2015-09-17_Andrew_PC/DOCS/2130419.doc /Volumes/Location/Workers/Andrew/2015-08-12_Andrew_PC/DOCS/3177109.doc /Volumes/Location/Workers/Charlie/2016-07-06_Charlie_PC/DOCS/4744123.doc </code></pre>