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

  • Home
  • SEARCH
  • 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 5945837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:44:16+00:00 2026-05-22T16:44:16+00:00

I have ~/bashpractice$ ls dir3 dir1 I get ~/bashpractice$ xargs ls -l dir1 dir3

  • 0

I have

~/bashpractice$ ls
dir3 dir1   

I get

~/bashpractice$ xargs ls -l 
dir1 dir3
dir1:
total 0
-rw-r--r-- 1 abc abc 0 2011-05-23 10:19 file1
-rw-r--r-- 1 abc abc 0 2011-05-23 10:19 file2

dir3:
total 0
-rw-r--r-- 1 abc abc 0 2011-05-23 10:20 file1
-rw-r--r-- 1 abc abc 0 2011-05-23 10:20 file2

But I get an error when I do

~/bashpractice$ xargs -0 ls -l
dir1 dir3
ls: cannot access dir1 dir3
: No such file or directory

abc@us-sjc1-922l:~/bashpractice$ xargs -0 ls -l
dir1
dir3 
ls: cannot access dir1
dir3
: No such file or directory

How to get a listing when specifying -0 option to xargs ?

  • 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-05-22T16:44:16+00:00Added an answer on May 22, 2026 at 4:44 pm

    For example – as told in the man xargs

    -0 Change xargs to expect NUL (“\0”)
    characters as separators, instead of
    spaces and newlines. This is expected
    to be used in concert with the -print0
    function in find(1).

    find . -print0 | xargs -0 echo
    

    The -0 tells xargs one thing: "Don’t separate input with spaces but with NULL char". It is useful usually in combination with find, when you need handle files and/or directories that contain space in their name.

    There are more commands what can play with -print0 – for example grep -z.


    Edit (based on comments)

    See Seth’s answer or this:

    ls -1 | perl -pe 's/\n/\0/;' > null_padded_file.bin
    xargs -0 < null_padded_file.bin
    

    But it is strange, why want use -0 if you don’t need to use it?. Like "Why want remove a file, if does not exist?". Simply, the -0 is needed to use only with combination, if the input is null-padded. Period. 🙂

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

Sidebar

Related Questions

Have a client who is looking at developing a site where clients get access
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you managed to get Aptana Studio debugging to work? I tried following this,
Have looked so long for a library specialized in dealing with iPhone Accelerometer but
Have String str May 23 2011 12:20:00, want to convert it to date such
Have just started to get into CakePHP since a couple of weeks back. I
Have a xml data like <Items><Item><name>test1</name></Item><Item><name>test2</name></Item></Items> Looks like jaxb cannot unmashall this when defining
Have a large amount of HTML, but where I thought the bottleneck would be
Have been scatching my head about this - and I reckon it's simple but
Have a (rather complex) app that works fine on iOS 4 but fails on

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.