Single quotes not working in shell script

I have a .bash_profile script and I cannot get the following to work alias lsls = 'ls -l | sort -n +4 '

when I print the alias lsls it performs sorting, but then sends this error message "- bash: +4: command not found" How to get the alias for working with "+4"?

It works when type ls -l | sort -n +4 on the command line

I'm on OS X 10.4

Thanks for any help

+3
source share
3 answers
bash-4.0$ ls -l | sort -n +4
sort: open failed: +4: No such file or directory

You need ls -l | sort -n -k 5gnu sorting is different from bsd sorting

alias lsls='ls -l | sort -n -k 5'

Edit: Updated to reflect the change from indexing based on 0 to indexing based on 1, thanks Matthew.

+4

alias lsls='ls -l | sort -n +4' sort OS X 10.4 ( ).

lsls, , "- bash: +4: "

, .bash_profile? - :

alias lsls='ls -l | sort -n
+4'

... .


, sort , :

ls -lrS
+1

, .

, .

0

Source: https://habr.com/ru/post/1729673/


All Articles