Homepage | Welcome visitor | Log inSign upSite MapPasser en français
Search

1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008

iSdlAir.com:
– Sdl's –
WeeklyNews

Lite Edition, Year 2008

Vol. 15, Mon. Sep. 8th, 2008 05:56
 
M C M L X X X I I :   T W E N T Y - S I X   Y E A R S   O F   P R O G R A M M I N G   A N D   T E C H N O L O G Y   D E S I G N 

BLOG
HODIE
CONSULTING M&A
2007
MOBILE EARTH
2006
WEB–TO–WIRELESS MMO
2005
WIRELESS MULTIPLAYER
2004
VIDEO GAMES TRACK RECORD
1994-2003
BEFORE
<1994
RÉSUMÉ
1990-2008

Linux bash enigma: ls |wc

June. 19th, 2008 17:59 by sdelucaPermalink | TrackBack: http://isdlair.com/trackback/835 | del.icio.us logoDel.icio.us — exists for 2 months & 2 weeks ago — Rate:

While working on an administrative shell script for our mobile location-based social networking service http://m.mobiluck.com I came accross a weird issue. Let me explain what I want first.

I am analysing incoming ads hits on our service, data mining the apache log file. I wanted to use a simple script in bash.

The point is to display how I grep the file for answering a question, and then display the result of the grep.

But as I came accross an issue, I will generalize it with this very simple script:

#!/bin/bash
c='ls |wc'; 
echo How many files in this folder:
echo "$c"; 
`$c`

I was expecting the following results:

How many files in this folder:
ls |wc 
      21      37     535

Unfortunately, I've got the following:

How many files in this folder:
ls |wc
ls: |wc: No such file or directory

Turning on the debug mode I've got the following:

+echo How many files in this folder:
How many files in this folder:
+ c='ls |wc'
+ echo 'ls |wc'
ls |wc
++ ls '|wc'
ls: |wc: No such file or directory

It appears that bash add simple quotes where it finds blank spaces. How it comes?

Any idea how to fix this?

Leave a comment | Reddit! |

Comments

Be the first to leave a comment.
Leave a comment No HTML tags allowed — Textile syntax appreciated




  Inform me when an answer is posted

Want to insert a photograph into your comment?
To insert a photo in your comment do the following:
1 — Choose one by clicking on Choose File button and select an image.
2 — Insert the special tag [image] in your text where you want it to appear.
3 — Validate your comment by cliking on the button.





If you have difficulties to read the code, click on the image.

Textile

A Humane Web Text Generator

what does it do?

Quick block modifiers:
Header: hn.
Blockquote: bq.
Footnote: fnn.
Numeric list: #
Bulleted list: *

Quick phrase modifiers:
_emphasis_
*strong*
??citation??
-deleted text-
+inserted text+
^superscript^
~subscript~
%span%

To apply attributes:
(class)
(#id)
{style}
[language]

To align blocks:
< right
> left
= center
<> justify

To insert a table:
|a|table|row|
|a|table|row|

To insert a link:
"linktext":url

To insert an image:
!imageurl!

To define an acronym:
ABC(Always Be Closing)

To reference a footnote:
[n]

Putting it all together

View sample input text


Advanced Features

<iphone src="url"/> : Display an iPhone Web application

<youtube src="url"/> : Display an YouTube video

<member username/> : Display an iPhone Web application

<iphone src="url"/> : Display an iPhone Web application

Smileys
[angry] :
[asleep] :
[clap] :
[cold] :
[cry] :
[dollars] :
[gift] :
[guru] :
[iloveyou] :
[laugh] :
[lol] :
[loving] :
[music] :
[shuss] :
[sick] :
[smile] :
[sport] :
[sweat] :
[unhappy] :
[wink] :
Copyright © 1994 ˜ 2008 dsei.biz / Stéphane de Luca — All Rights Reserved | 05:56 AM RSS RSS Feed  | Best viewed with Apple logo Safari