473,378 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Bash Process Substitution

In this sequence at the command prompt
Expand|Select|Wrap|Line Numbers
  1. $ x=()
  2. $ { while read;  do  x+=("$REPLY"); done; } <<<"$(ls)"
  3. $ printf 'count=%d\n' ${#x[@]}
  4. count=432
  5. $ wc -l <(ls)
  6.      432 /dev/fd/63
  7. $ { while read;  do  x+=("$REPLY"); done; } <(ls)
  8. -bash: syntax error near unexpected token `<(ls)'
  9.  
what causes the error noted?

Doing
Expand|Select|Wrap|Line Numbers
  1. $ x=()
  2. $ ls | { while read; do x+=("$REPLY"); done }
  3. $  printf 'count=%d\n' ${#x[@]}
  4. count=0
  5. $
  6. $
runs without error, but executes the loop in a subprocess, losing the results on termination
BASH 3.2.57(1)-release on OS X 10.10.5
Feb 28 '16 #1
1 4736
numberwhun
3,509 Expert Mod 2GB
Have you tried adding a $ before the (ls), like so:

Expand|Select|Wrap|Line Numbers
  1. { while read;  do  x+=("$REPLY"); done; } < $(ls)
  2.  
May 23 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bernhard Kuemel | last post by:
Hi! To relief the problems of accessing a unix machine from behind a restrictive firewall or from an internet cafe I started to make a PHP web interface to bash. I'd like to hear your opinions...
6
by: Lukas Holcik | last post by:
Hi Python crazies!:)) There is a problem to be solved. I have a text and I have to parse it using a lot of regular expressions. In (lin)u(ni)x I could write in bash: cat file | sed 's/../../' |...
1
by: Goblin | last post by:
Hello i have a little code for updating somethink in my SQL database. I get the error: bash: /root/remstats.pl: /usr/bin/perl: bad interpreter: Permission denied Can someone tell me what's wrong?...
1
by: Panagiotis | last post by:
Hi everyone, this is what I want to do in C#: 1) start a Cygwin Bash Shell 2) send the Shell a command, for example "ls -l" 3) capture all the output of the command The code below seems to...
3
by: kneielj | last post by:
How does the shell interpret command substitution ? if its a normal command, the shell would spawn a child process and the parent would wait for the child to execute and would then collect its exit...
0
by: lokeshrajoria | last post by:
Hello Everyone, Please go through this script code . this script files executing in bash 2.05 version without mentioning sh. That means if I type simple in command prompt :...
4
by: melmack3 | last post by:
Hello My PHP script executes many bash/cmd commands. Functions like "exec()" or "system()" cause that new bash/cmd session is started, the command is executed and the session is closed....
3
by: Karim Bernardet | last post by:
Hi I am using pexpect to do ssh tunneling and to open a vnc server (jobs on a grid cluster). When the job is canceled, these 2 processes remain on the worker node (they are detached), so I have...
1
by: Gros Bedo | last post by:
Yes I've seen that each python script calls its own instance of Python. Buthow to know which is the good one in bash ? Is there a command that gets the parameters of process, so I could use grep to...
0
by: norseman | last post by:
Gros Bedo wrote: ============================== Yes. man ps explains try ps -AFL | grep then kill -9 found (check it more than twice) 1) If your script is known to hang use what...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.