ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Problem sorting using '/' as a field separator
Old hand at sort? Here's one for ya...
I have a file full of paths and files obtained from a "find * -type f | sort" command that looks something like (the directories and filenames have been changed to protect the innocent):
Which gives me a sorted listing but the listing for directory "a" is interrupted by the list of files in "a/a_f/". What I'd like to do is reorder this to something like:
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Original Poster
Rep:
Quote:
Originally Posted by NevemTeve
How about 'find . -s'?
"-s"? Not familiar with that switch on any Unix/Linux variant I've ever used. (My OpenSUSE manpages and info are coming up dry when I search for that.) And... it returns:
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Original Poster
Rep:
Quote:
Originally Posted by syg00
No collating sequence I know will allow sort to put "g" before "f" (in an ascending sort). Forlorn hope for sort to do it unaided IMHO.
Well I had been trying to convince sort to pull that off with the '/' as a delimiter. Of course, I realize that sort doesn't care about the difference between files and directories but thought there might be a way. (I obviously don't use sort enough, I guess. Just the basics.)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Original Poster
Rep:
Quote:
Originally Posted by AnanthaP
tree ?
That might work.
My goal was/is to generate a listing of directories that I can cut-n-paste from to send off to users to have them clean up or, in other cases, get back to me so I know which files can be tarred up (which files go in what archives, etc.) or, preferably, the users will have a short command they can use /themselves/ before they tackle those tasks. (Hey! A guy can dream, can't he?)
I'll have to look whether the admins at the site I'm working with even bothered to install 'tree'. On my home systems, only my ancient RedHat system has it installed -- and I'm pretty sure I went with a barebones install on that one. If it's not there, I'll be stuck on square one. I'll check tomorrow.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.