display ls output in 2 columns with directories in one and files in the other

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Can you make an alias command that basically formats the out put of ls into two columns, so that the output shows all the subdirectories in column 1 and all the files in column 2.



Example:



me:~$ ls
dir1 file1.txt
dir2 file2.xml
dir3 file3.pdf
dir4 file4.png
dir5 file5.wav
dir6 file6.mp3
... file7.doc
...


You get the idea :) (Maybe even put the executables in column 3?)



Is this possible?



OS version: Ubuntu 18.04










share|improve this question























  • Is there a particular reason why you removed all those things @Rui F Ribeiro ? Was it too personal?
    – Ciarán J. Hagen
    Dec 6 at 11:20










  • It might be in your interest keeping your posts succinct and on topic, for getting more attention and up voting. There is also a tradition of editing posts here for consistency and redundancy. See our FAQ and keep around. btw, welcome.
    – Rui F Ribeiro
    Dec 6 at 11:46











  • I will keep that in mind for future posts :D Thx
    – Ciarán J. Hagen
    Dec 6 at 13:08














up vote
0
down vote

favorite












Can you make an alias command that basically formats the out put of ls into two columns, so that the output shows all the subdirectories in column 1 and all the files in column 2.



Example:



me:~$ ls
dir1 file1.txt
dir2 file2.xml
dir3 file3.pdf
dir4 file4.png
dir5 file5.wav
dir6 file6.mp3
... file7.doc
...


You get the idea :) (Maybe even put the executables in column 3?)



Is this possible?



OS version: Ubuntu 18.04










share|improve this question























  • Is there a particular reason why you removed all those things @Rui F Ribeiro ? Was it too personal?
    – Ciarán J. Hagen
    Dec 6 at 11:20










  • It might be in your interest keeping your posts succinct and on topic, for getting more attention and up voting. There is also a tradition of editing posts here for consistency and redundancy. See our FAQ and keep around. btw, welcome.
    – Rui F Ribeiro
    Dec 6 at 11:46











  • I will keep that in mind for future posts :D Thx
    – Ciarán J. Hagen
    Dec 6 at 13:08












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Can you make an alias command that basically formats the out put of ls into two columns, so that the output shows all the subdirectories in column 1 and all the files in column 2.



Example:



me:~$ ls
dir1 file1.txt
dir2 file2.xml
dir3 file3.pdf
dir4 file4.png
dir5 file5.wav
dir6 file6.mp3
... file7.doc
...


You get the idea :) (Maybe even put the executables in column 3?)



Is this possible?



OS version: Ubuntu 18.04










share|improve this question















Can you make an alias command that basically formats the out put of ls into two columns, so that the output shows all the subdirectories in column 1 and all the files in column 2.



Example:



me:~$ ls
dir1 file1.txt
dir2 file2.xml
dir3 file3.pdf
dir4 file4.png
dir5 file5.wav
dir6 file6.mp3
... file7.doc
...


You get the idea :) (Maybe even put the executables in column 3?)



Is this possible?



OS version: Ubuntu 18.04







terminal ls






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 6 at 13:15

























asked Dec 6 at 10:40









Ciarán J. Hagen

33




33











  • Is there a particular reason why you removed all those things @Rui F Ribeiro ? Was it too personal?
    – Ciarán J. Hagen
    Dec 6 at 11:20










  • It might be in your interest keeping your posts succinct and on topic, for getting more attention and up voting. There is also a tradition of editing posts here for consistency and redundancy. See our FAQ and keep around. btw, welcome.
    – Rui F Ribeiro
    Dec 6 at 11:46











  • I will keep that in mind for future posts :D Thx
    – Ciarán J. Hagen
    Dec 6 at 13:08
















  • Is there a particular reason why you removed all those things @Rui F Ribeiro ? Was it too personal?
    – Ciarán J. Hagen
    Dec 6 at 11:20










  • It might be in your interest keeping your posts succinct and on topic, for getting more attention and up voting. There is also a tradition of editing posts here for consistency and redundancy. See our FAQ and keep around. btw, welcome.
    – Rui F Ribeiro
    Dec 6 at 11:46











  • I will keep that in mind for future posts :D Thx
    – Ciarán J. Hagen
    Dec 6 at 13:08















Is there a particular reason why you removed all those things @Rui F Ribeiro ? Was it too personal?
– Ciarán J. Hagen
Dec 6 at 11:20




Is there a particular reason why you removed all those things @Rui F Ribeiro ? Was it too personal?
– Ciarán J. Hagen
Dec 6 at 11:20












It might be in your interest keeping your posts succinct and on topic, for getting more attention and up voting. There is also a tradition of editing posts here for consistency and redundancy. See our FAQ and keep around. btw, welcome.
– Rui F Ribeiro
Dec 6 at 11:46





It might be in your interest keeping your posts succinct and on topic, for getting more attention and up voting. There is also a tradition of editing posts here for consistency and redundancy. See our FAQ and keep around. btw, welcome.
– Rui F Ribeiro
Dec 6 at 11:46













I will keep that in mind for future posts :D Thx
– Ciarán J. Hagen
Dec 6 at 13:08




I will keep that in mind for future posts :D Thx
– Ciarán J. Hagen
Dec 6 at 13:08










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










stat around (you didn't comment on your OS version)? try



stat -c$'%Fn%n' * | awk '/^directory/ getline LEFT[++DC]; next getline RIGHT[++FC] END for (i=1; i<=(DC>FC?DC:FC); i++) print LEFT[i], RIGHT[i]' OFS="t"
dir1 awkscript
dir2 fil1
dir3 file
dir4 file~
file1
file1~
file2





share|improve this answer




















  • This is what I'm looking for, only it prints column 2 relative to column 1. This makes the second column non-parallell. Is there a way to fix this?
    – Ciarán J. Hagen
    Dec 6 at 13:08










  • btw OS version: Ubuntu 18.04 Bionic Beaver
    – Ciarán J. Hagen
    Dec 6 at 13:14










  • pipe it through column -nt.
    – RudiC
    Dec 6 at 13:20










  • Thank you so much :D It works now
    – Ciarán J. Hagen
    Dec 6 at 13:43










  • There is one small problem still, in that it prints files with a whitespace in their filename in two columns... Is there a way to remedy this?
    – Ciarán J. Hagen
    Dec 7 at 14:33










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486342%2fdisplay-ls-output-in-2-columns-with-directories-in-one-and-files-in-the-other%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










stat around (you didn't comment on your OS version)? try



stat -c$'%Fn%n' * | awk '/^directory/ getline LEFT[++DC]; next getline RIGHT[++FC] END for (i=1; i<=(DC>FC?DC:FC); i++) print LEFT[i], RIGHT[i]' OFS="t"
dir1 awkscript
dir2 fil1
dir3 file
dir4 file~
file1
file1~
file2





share|improve this answer




















  • This is what I'm looking for, only it prints column 2 relative to column 1. This makes the second column non-parallell. Is there a way to fix this?
    – Ciarán J. Hagen
    Dec 6 at 13:08










  • btw OS version: Ubuntu 18.04 Bionic Beaver
    – Ciarán J. Hagen
    Dec 6 at 13:14










  • pipe it through column -nt.
    – RudiC
    Dec 6 at 13:20










  • Thank you so much :D It works now
    – Ciarán J. Hagen
    Dec 6 at 13:43










  • There is one small problem still, in that it prints files with a whitespace in their filename in two columns... Is there a way to remedy this?
    – Ciarán J. Hagen
    Dec 7 at 14:33














up vote
0
down vote



accepted










stat around (you didn't comment on your OS version)? try



stat -c$'%Fn%n' * | awk '/^directory/ getline LEFT[++DC]; next getline RIGHT[++FC] END for (i=1; i<=(DC>FC?DC:FC); i++) print LEFT[i], RIGHT[i]' OFS="t"
dir1 awkscript
dir2 fil1
dir3 file
dir4 file~
file1
file1~
file2





share|improve this answer




















  • This is what I'm looking for, only it prints column 2 relative to column 1. This makes the second column non-parallell. Is there a way to fix this?
    – Ciarán J. Hagen
    Dec 6 at 13:08










  • btw OS version: Ubuntu 18.04 Bionic Beaver
    – Ciarán J. Hagen
    Dec 6 at 13:14










  • pipe it through column -nt.
    – RudiC
    Dec 6 at 13:20










  • Thank you so much :D It works now
    – Ciarán J. Hagen
    Dec 6 at 13:43










  • There is one small problem still, in that it prints files with a whitespace in their filename in two columns... Is there a way to remedy this?
    – Ciarán J. Hagen
    Dec 7 at 14:33












up vote
0
down vote



accepted







up vote
0
down vote



accepted






stat around (you didn't comment on your OS version)? try



stat -c$'%Fn%n' * | awk '/^directory/ getline LEFT[++DC]; next getline RIGHT[++FC] END for (i=1; i<=(DC>FC?DC:FC); i++) print LEFT[i], RIGHT[i]' OFS="t"
dir1 awkscript
dir2 fil1
dir3 file
dir4 file~
file1
file1~
file2





share|improve this answer












stat around (you didn't comment on your OS version)? try



stat -c$'%Fn%n' * | awk '/^directory/ getline LEFT[++DC]; next getline RIGHT[++FC] END for (i=1; i<=(DC>FC?DC:FC); i++) print LEFT[i], RIGHT[i]' OFS="t"
dir1 awkscript
dir2 fil1
dir3 file
dir4 file~
file1
file1~
file2






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 6 at 11:52









RudiC

3,9541312




3,9541312











  • This is what I'm looking for, only it prints column 2 relative to column 1. This makes the second column non-parallell. Is there a way to fix this?
    – Ciarán J. Hagen
    Dec 6 at 13:08










  • btw OS version: Ubuntu 18.04 Bionic Beaver
    – Ciarán J. Hagen
    Dec 6 at 13:14










  • pipe it through column -nt.
    – RudiC
    Dec 6 at 13:20










  • Thank you so much :D It works now
    – Ciarán J. Hagen
    Dec 6 at 13:43










  • There is one small problem still, in that it prints files with a whitespace in their filename in two columns... Is there a way to remedy this?
    – Ciarán J. Hagen
    Dec 7 at 14:33
















  • This is what I'm looking for, only it prints column 2 relative to column 1. This makes the second column non-parallell. Is there a way to fix this?
    – Ciarán J. Hagen
    Dec 6 at 13:08










  • btw OS version: Ubuntu 18.04 Bionic Beaver
    – Ciarán J. Hagen
    Dec 6 at 13:14










  • pipe it through column -nt.
    – RudiC
    Dec 6 at 13:20










  • Thank you so much :D It works now
    – Ciarán J. Hagen
    Dec 6 at 13:43










  • There is one small problem still, in that it prints files with a whitespace in their filename in two columns... Is there a way to remedy this?
    – Ciarán J. Hagen
    Dec 7 at 14:33















This is what I'm looking for, only it prints column 2 relative to column 1. This makes the second column non-parallell. Is there a way to fix this?
– Ciarán J. Hagen
Dec 6 at 13:08




This is what I'm looking for, only it prints column 2 relative to column 1. This makes the second column non-parallell. Is there a way to fix this?
– Ciarán J. Hagen
Dec 6 at 13:08












btw OS version: Ubuntu 18.04 Bionic Beaver
– Ciarán J. Hagen
Dec 6 at 13:14




btw OS version: Ubuntu 18.04 Bionic Beaver
– Ciarán J. Hagen
Dec 6 at 13:14












pipe it through column -nt.
– RudiC
Dec 6 at 13:20




pipe it through column -nt.
– RudiC
Dec 6 at 13:20












Thank you so much :D It works now
– Ciarán J. Hagen
Dec 6 at 13:43




Thank you so much :D It works now
– Ciarán J. Hagen
Dec 6 at 13:43












There is one small problem still, in that it prints files with a whitespace in their filename in two columns... Is there a way to remedy this?
– Ciarán J. Hagen
Dec 7 at 14:33




There is one small problem still, in that it prints files with a whitespace in their filename in two columns... Is there a way to remedy this?
– Ciarán J. Hagen
Dec 7 at 14:33

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486342%2fdisplay-ls-output-in-2-columns-with-directories-in-one-and-files-in-the-other%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?