Shell programming ~ Encountered a problem ~ Who can explain it?
Source: Internet
Author: User
Shell programming ~ Encountered a problem ~ Who can explain-Linux general technology-Linux technology and application information? The following is a detailed description. The problems I encountered during programming are simplified as follows:
1) generate a file:
$ Echo-n "abcd"> file
2) write a script (bash environment) to read the file:
$ Cat f1
#! /Bin/bash
While read
Do
Echo $
Done <file
No data is found ~~~
However, if the while statement is not used, you can read the following:
$ Cat f2
#! /Bin/bash
Read a <file
Echo $
I tried it for a long time and found it related to '-n' in my echo statement. After this option is added, I cannot read data using the while statement. Why ?? Looking forward to expert answers! Thank you!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service