3

When I execute a command in Ubuntu, which results in a listing, I get results without the field names. Example is ls -l or ps l.

I am not very experienced and always need to go digging through man pages and online documentation. And the names are quite crypcit already.

Is there a way to turn on field name listing globally i.e. for all commands?

Note: actually ps l shows field names, while ls -l does not. It is true that the second is very trivial. However, the question stands - is there a way to overwrite this behaviour?

2

As @StephaneChazelas stated this isn't possible. You're only other options are to modify the source (don't do this) and/or develop some wrapper scripts and aliases for yourself to assist.

There is this technique for preserving the columns of ps in output that you're going to pipe to sort.

I would take this as an opportunity to hone your alias/scripting skills by putting together the pieces that you need. Much of using Unix/Linux is in tricking out your environment so that things are more accessible to your work habits and style.

1

Following slm's advice, the following script might help. Check the following script.It will build labels for the fields in ls -l command.I have used the column utility (a BSD extension, but it also comes with most Linux distros).It is included in the util-linux package.

#!/bin/bash
{ echo Permissions links Owner Group Size Last_modMonth Last_modTime Last_modTime Filename; ls -l ; } | column -t | awk 'NR!~/^(2)$/'
ls -l | head -1

You can alias it and use this.

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.