Shell appears syntax error near unexpected token ' < ' workaround

Source: Internet
Author: User

The latest when looking at a shell data, according to the textbook, but the following error, can not run

As follows, the simple script:

#!/bin/bashcat |  while Read Line  do  Echo $line  Done < < (data.txt|  awk'{print $}')

The following error occurred while running

sh while_test. SH while_test. SH 5: syntax error near unexpected token ' <'while_test. SH 5: ' Done < < (data.txt|  awk'{print $}')'

And then run it in a single line without errors

 while read line;  Do echo $line;  Done < < (cat data.txt|  awk'{print $}')1234

After the online view, confirm no footstep error, no DOS file error. There is no good way out. Through multi-party verification. The original is Bash 3.0, the shell has added a new symbol "<<<" to get sub-tasks

The script is now changed as follows to run successfully:

#!/bin/bashcat |  while Read Line  do  Echo $line  done <<< 'cat data.txt| awk ' {print $} "'

Run successfully

sh while_test. SH 1 2 3 4

Shell appears syntax error near unexpected token ' < ' workaround

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.