1833873 Members
2504 Online
110063 Solutions
New Discussion

Need Help with command

 
SOLVED
Go to solution
Mike_305
Super Advisor

Need Help with command

Hello,

Trying to sort the files under "/dev" and running the following command and it's not working. What am I doing incorrect.

ll /dev/*/group | awk '(printf $6 "\n")' | sort -n

I am doing this to find out what is the next number I can use for mknod command.

Thanks in advance!


MP
If there is problem then don't think as problem, think as opportunity.
7 REPLIES 7
James R. Ferguson
Acclaimed Contributor
Solution

Re: Need Help with command

Hi:

# ls -l /dev/*/group | awk '{printf "%s\n", $6}' | sort -n

Regards!

...JRF...
TTr
Honored Contributor

Re: Need Help with command

ll /dev/*/group | sort -k6,6

The -k option of sort is very powerful. Character or numeric sorting covers the hex nature of the minor number

If you want to be more specific

ll /dev/*/group | sort -k6.3,6.4
Mike_305
Super Advisor

Re: Need Help with command

Hello,

Thanks for the quick reply. Both of you guys are de "MAN".

It is always help having the right syntax in the command.

This one gives me what I was looking for and it's easy to determine which next "HEX" number I can use for my MKNOD.

Appreciate your help.

THX - MP
If there is problem then don't think as problem, think as opportunity.
Dennis Handly
Acclaimed Contributor

Re: Need Help with command

>ll /dev/*/group | awk '(printf $6 "\n")' | sort -n

Instead of using awk's printf, you could just use: print $6
You could also print the filename.
Mike_305
Super Advisor

Re: Need Help with command

Hello Dennis,

I had the same command line and the option that you suggested does not work.

Thanks for your help.

Thanks,

MP
If there is problem then don't think as problem, think as opportunity.
Mike_305
Super Advisor

Re: Need Help with command

Hello,

thanks for your help. The only command works is James and TTr's.

Thanks for your help.

Thanks,

MP
If there is problem then don't think as problem, think as opportunity.
Dennis Handly
Acclaimed Contributor

Re: Need Help with command

>I had the same command line and the option that you suggested does not work.

Sorry, I was copying your line and just suggesting you not use printf. I didn't notice you had () vs {}.
So here would be my suggestion combining the JRF and my filename solutions:
ll /dev/*/group | awk '{print $6,$10}' | sort