Hot answers tagged

10

You can use the shell's sort order instead (which may not involve the locale's collation order; bash, AT&T ksh, yash, tcsh and zsh give the expected results, mksh and dash don't. fish seems to give a case insensitive order but gives different results when there are non-ASCII characters): ls -dUl -- .* * This gives ls an explicit list of files (and ...


5

You could use find, which (on many platforms) has an -ls option. So you could do find . -maxdepth 1 -name '*' -ls But if it is hard to remember ls -d, you may not find find an improvement.


4

You might simply use two separate ls commands: $ ls -dl ..?* .[^.]* 2>/dev/null ; ls -dl * -rw-r--r--. 1 sparhawk sparhawk 0 8 Jun 09:29 .a -rw-r--r--. 1 sparhawk sparhawk 0 8 Jun 09:29 .b -rw-r--r--. 1 sparhawk sparhawk 0 8 Jun 09:29 a -rw-r--r--. 1 sparhawk sparhawk 0 8 Jun 09:29 A -rw-r--r--. 1 sparhawk sparhawk 0 8 Jun 09:29 b -rw-r--r--. 1 ...


3

No ls -l | wc -l will report the number of lines the ls -l command would give. Roughly the number of files+directories in the current directory plus something for the header.


3

While doing: find /data/code/ -name "*.jar" -exec {} ls \; you are trying the execute the file found (e.g. /data/code/project/shared/build/thirdparty/log4j-1.2.8/commons-logging-1.0.4.jar) with ls as an argument to it, leading to the permission denied error. Just switch the order: find /data/code/ -name "*.jar" -exec ls {} \; GNU find has -ls option ...


2

Yes, and also symlinks and sockets. And the first line (there are several questions here about what that number means) will also be counted. But you'll typically only find devices in /dev (with subdirectories) and there's typically very few files there, so I'm wondering if that's really what you want to do. What are you trying to accomplish? Also ls ...


2

As you mentioned in the comment you want to check current date's file in remote directory, you can do that in following manner: FILE=$(ssh -q "$USER"@"$HOST" 'find /home/oracle/SABARISH/logs/sftp -type f -daystart -mtime -1 | wc -l') if test "$FILE" -eq 0; then exit else # do your SFTP stuff here fi from man find : -daystart Measure ...


2

You can do something like this: files=$( ls -l --time-style=+%D | grep $(date +%D) | grep -v '^d' | awk '{print $NF}' ) ; for f in $files ; do cp -rf $f /home/oracle/SABARISH/logs/files/ ; done ; sftp {user}@{host}:{remote_dir} <<< 'put /home/oracle/SABARISH/logs/files/*' or similarly: for f in $(ls -l --time-style=+%D | grep $(date +%D) | grep -...


1

from man ls -h, --human-readable with -l and/or -s, print human readable sizes (e.g., 1K 234M 2G) Meaning that it will display file sizes using K, M, G postfixes: 1K = 1024, 1M = 1024K, 1G = 1024M (all in bytes). see http://www.athropolis.com/popup/c-comp2.htm This is very similar to how the metric (SI) system works ( 1000μ = ...


1

If what you want is a command cmd so that cmd cr* lists cron.daily itself, then that command is ls -d. If that's too much typing, you can define an alias. For example, put this line in your ~/.bashrc: alias l='ls -d' Then running l cr* will display information about cron.daily itself, while ls cr* will list the contents of the directory cron.daily (and of ...


1

I recommend to use zsh shell for this job: cp *(m-1) /home/oracle/SABARISH/logs/files/ where (m-1) is so called glob qualifier. In this case we select all (*) files modified (m) within (-) last (1) day.


1

ls -l will display how many files contain the currunt directory and in long format. in total n files +1 line for total X as header. | wc -l counts the total lines that is fed so in total you will have n+1 (lines+(1)header after executing ls -l | wc -l


1

It will show the number of lines output by ls -l which will include everything that has an entry in the current directory, including files (including special files if present), links, and directories.



Only top voted, non community-wiki answers of a minimum length are eligible