2

I want to know the size of all the data files in my directory. I tried using the following command. The file names all start with data_.

 find . -name 'data_*' -type f  | xargs ls -sh -n1 -p

I do get the list of files with the the details as shown below:

-rw-r--r-- 1 1826696135 1826619905 4.5K Apr  7 16:48 ./data_70
-rw-r--r-- 1 1826696135 1826619905 4.5K Apr  7 16:48 ./data_71
-rw-r--r-- 1 1826696135 1826619905 4.5K Apr  7 16:48 ./data_72
-rw-r--r-- 1 1826696135 1826619905 4.6K Apr  7 16:48 ./data_73
-rw-r--r-- 1 1826696135 1826619905 4.5K Apr  7 16:48 ./data_74

However, xargs never prompted me. Since I am using -p -n1, I would expect the program to prompt me after each line. What is wrong?

dhag
  • 15,736
  • 4
  • 55
  • 65
liv2hak
  • 163
  • 5

1 Answers1

6

Try xargs -n1 -p ls -sh. Using what is in your question, xargs ls -sh -n1 -p, everything is passed to ls, rather than some of the options being used by xargs.

dhag
  • 15,736
  • 4
  • 55
  • 65