Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:33:53+00:00 2026-06-14T22:33:53+00:00

I have a directory that has 108k files in it. I am using the

  • 0

I have a directory that has 108k files in it.
I am using the KSH shell on RHEL5

ls *
-dash_bin_ksh: ls: /bin/ls: cannot execute [Argument list too long]

Only command that seems to work is the find command.

find .
file 1
file 2 
file n

I tried using find with then exec option to run the file command but I am not getting anywhere.

find . -exec file {}
find: missing argument to `-exec'

What am I missing? I just want to run the file command on every file in this directory and output to a file_output.txt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:33:54+00:00Added an answer on June 14, 2026 at 10:33 pm

    For find’s exec, you have to end the argument with with \;

    You can also try:

    find . -print0 | xargs -0 file
    

    xargs works by taking its STDIN and adding each element (line or delimited string) as an argument to the given executable to be executed as few times as possible. The argument list is split by –max-chars (Platform dependent upto 128Kib) into groups for execution.

    -print0 adds null chars instead of new lines which makes it safe for file names with spaces. -0 on xargs is used to recognise null chars.

    -print0 and -0 are GNU extensions and can be dropped for non GNU environments at the cost of versatility.

    xargs also has the -I option which makes it work more like find -exec where the executable is run for each element.

    Thanks to @glennjackman for his in-depth knowledge on this subject.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that has a /sites/default/files/ directory where user content is typically
I have a directory that has the following files Build asc2uni.c asc2uni.1 I have
I have a directory that has 8K files at the moment. Over the next
I have a directory tmp that has 3 test node.js modules [mod0.js, mod1.js, mod2.js]
I have a source directory that includes a mix of different languages and files.
i have directory that has 2 sub-directories and that again has few sub-directory and
I have a directory of source files (.h and .m) that are shared between
Consider I have a directory called root that has two directories: x and y
Let's say I have to read from a directory that has many large XML
I have an authenticated directory in my site that has a bunch of directories

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.