Saturday, May 4, 2024
15
rated 0 times [  15] [ 0]  / answers: 1 / hits: 1013  / 2 Years ago, sat, june 18, 2022, 9:44:35

I know that these two commands do the same thing:



ls -la
ls -al


but I'm wondering if there is any preference between them. Is it better practice to order them in a certain way?


More From » command-line

 Answers
7

It does not really matter* unless a command explicitly mentions. I have came across no reference that gave anything like a guideline how to put the options one after another. So I think for the sake of readability the options can be arranged alphabetically.



*There is a very very important cavaet that is if any option needs a filename or any other input right after it you need to put it accordingly.



For example, the -f option of grep takes a file as input to take the pattern to look for from the input file. You need to give the command as e.g.:



grep -cf input.txt file.txt 


If you use it like:



grep -fc input.txt file.txt 


it will fail as it will use c as a file name.


[#19615] Monday, June 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ugeeport

Total Points: 181
Total Questions: 108
Total Answers: 99

Location: El Salvador
Member since Tue, Jun 29, 2021
3 Years ago
;