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 7655609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:33:20+00:00 2026-05-31T12:33:20+00:00

I really dont understand why this is happening, bash seems to remove commands while

  • 0

I really dont understand why this is happening, bash seems to remove commands while running in a while loop.
I have the following script:

adb shell ls /foo/bar | while read file 
do
    folder="/foo/bar/$file"                                                                                                                                                                                                                                                    
    adb pull $folder download
done

when i run the command seperatly, it works great. But wen i run it like this, i get the following output:

' does not existfoo/bar/filesdfsdf.sdf

for every file in /foo/bar.

SO i tried to give me the command back as string, i changed to echo "adb pull $folder download" and got the following output:

 download/foo/bar/fileasdfs.sdf

for each line. It seems that bash does something with the string and replaces some stuff here…
If i use ', so no bash replacement would occur, i get the correct output.

whats happening here?

EDIT: I figured out that not while is directly broken, its the adb shell command what echoes a CRLF on every line end. if i use

adb shell ls /foo/bar | tr -d '\015' | while read file 
do
    folder="/foo/bar/$file"                                                                                                                                                                                                                                                    
    adb pull $folder download
done

it works!
But why is bash so allergic to CRLF? And why its deletes comnmands?

  • 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-31T12:33:21+00:00Added an answer on May 31, 2026 at 12:33 pm

    I don’t know what you mean by “Why does while not allow CR?”. The correct question is “What does read do with CR?”. Unless stating otherwise, read uses CR for parameter splitting. Look in your bash-manual for the variable IFS, and have a look at the -d option to read.

    Example:

    bos:$ echo foo bar gazonk | while read x ; do echo $x ; done
    foo bar gazonk
    

    Here, the CR acts as (default) delimiter for read. Now, say you want to split the read at every word, then you would use -d " " (setting SPC as delimiter):

    $ echo foo bar gazonk hello 123 | while read -d " " x ; do echo $x ; done
    foo
    bar
    gazonk
    hello
    

    The backside here is that the last parameter (123) is not output because it does not end with a delimiter. Think of the delimiter as grabbing everything LEFT of it, up to but not including the next delimiter. Since “123” does not end with a delimiter, the last delimiter is between “hello” and “123”, and – thus – what’s grabbed is “hello” because it has a delimiter to left and to right of it.

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

Sidebar

Related Questions

I am writing this because I have really no idea why this is happening.
I really don't understand regular expressions and was wondering what the following regular expressions
I have a really weird thing happening in my wpf application. Every time I
I really don't understand this. I downloaded the recent version of xCode 3.2.5 and
I don't really understand what is happening and maybe you can give me an
I am having trouble removing a column which is indexed. I dont really understand
I really don't understand the fascination with XHTML strict. Inline JavaScript typically requires a
I'm guessing there's something really basic about C# inheritance that I don't understand. Would
I think shoulda is really neat, but what I don't understand is why some
http://clang.llvm.org/docs/BlockLanguageSpec.txt Looks really cool. However, I don't understand it. I don't see examples it.

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.