Ubuntu$ ls -1
file1 file2
Ubuntu$ ls -1 | xargs -I{} echo -n {}{}{}
file1file1file1file2file2file2
Why don’t I get the result in this order?: file1file2file1file2file1fil2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Because
xargsexecutes the command (echo) for each word in its input. And of course{}is the same each time. Even if you repeat it many times.You can do what you want using
for:Example of usage: