RSS
DaniWeb Home
>
Forums
>
Software Development
>
Shell Scripting
Pipe inside variable isn't working in bash
Please support our
Shell Scripting
advertiser:
Programming Forums
Thread Tools
Display Modes
Views:
7682
| Replies:
2
•
•
•
•
•
•
Join Date: Jul 2003
Location: Brazil
Posts: 13
Reputation:
Rep Power:
6
Solved Threads: 0
Reginald0
Offline
Newbie Poster
Pipe inside variable isn't working in bash
#
1
Jan 30th, 2004
Hi, folks!
See the examples:
bash$ X="ls"; $X
file1 file2 file3
*** Works correctly!
bash$ X="ls | wc"; $X
ls: |: No such file or directory
ls: wc: No such file or directory
*** Doesn't work!
How to make the last command work correctly as first?
Thanks in advance!
Reginald0
Reginald0
View Public Profile
Send a private message to Reginald0
Find all posts by Reginald0
•
•
Join Date: Jan 2004
Posts: 1
Reputation:
Rep Power:
0
Solved Threads: 0
juppe10a
Offline
Newbie Poster
Re: Pipe inside variable isn't working in bash
#
2
Jan 30th, 2004
Hi,
if you want to store command result in variable use back quote:
# X=`ls | wc`
# echo $X.
or use command alias:
# alias X="ls | wc"
# X
juppe10a
View Public Profile
Send a private message to juppe10a
Find all posts by juppe10a
•
•
Join Date: Jul 2003
Location: Brazil
Posts: 13
Reputation:
Rep Power:
6
Solved Threads: 0
Reginald0
Offline
Newbie Poster
Re: Pipe inside variable isn't working in bash
#
3
Jan 30th, 2004
juppe10a,
It's not exactly what I was looking for, cause the command result isn't important to store to a variable, but the command execution itself.
I found a perfect way to do that:
# X="ls | wc"; eval $X
Simple but functional.
Thanks anyway!
Reginald0
Reginald0
View Public Profile
Send a private message to Reginald0
Find all posts by Reginald0
Quick Reply to Thread
•
•
•
•
Only community members can participate in forum threads. You must
register
or log in to contribute.
Register
•
•
•
•
Currently Active Users Viewing This Thread: 1
(0 members and 1 guests)
•
•
•
•
Thread Tools
Display Modes
Show Printable Version
Email this Page
Switch to Linear Mode
Hybrid Mode
Switch to Threaded Mode
Related Features
•
•
•
•
Shell Scripting Forum
Software Development Forum
Software Development Blog
bash Code Snippets
Shell Scripting Forum Highlights
Today's Posts
Shell Scripting
Software Development
All Forums
Unanswered Threads
Shell Scripting
Software Development
All Forums
Blog Tag Cloud
•
•
•
•
age
animations
business
environment
flash
ibm. news
interactivity.
it
multimedia
news
remote working
scripting
trends
web development
working
All Recent Tags
Similar Threads
how do i use php?id and what are they?
(PHP)
How to add printing features
(Perl)
StringTokenizer: To searh and replace a word.
(Java)
Working with JLayeredPane and positioning of components.. HELP!
(Java)
Jscript Replace Function
(ASP)
I have very bad problem but very to solve for u peoples
(Networking Hardware Configuration)
Other Threads in the Shell Scripting Forum
Previous Thread:
$paths
Next Thread:
C++ and CGI
Forums
|
Blogs
|
Tutorials
|
Code Snippets
|
Whitepapers
|
RSS Feeds
|
Advertising
All times are GMT -4. The time now is
12:07 pm
.
Newsletter Archive
-
Sitemap
-
Privacy Statement
-
Acceptable Use Policy
-
Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC