|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Check
Code:
echo "2012-12-26--14.8224 2012-12-27--14.2898 2012-12-28--14.9180 2012-12-29--13.3637 2012-12-30--13.7091" the set of numbers i provided above is separated by spaces. how do i count how many sets there are? i tried: Code:
echo "2012-12-26--14.8224 2012-12-27--14.2898 2012-12-28--14.9180 2012-12-29--13.3637 2012-12-30--13.7091" | wc -w ---------- Post updated at 10:57 AM ---------- Previous update was at 10:56 AM ---------- actually never mind, i think i may have found the solution: Code:
echo ""2012-12-26--14.8224 2012-12-27--14.2898 2012-12-28--14.9180 2012-12-29--13.3637 2012-12-30--13.7091"" | wc -w notice the double quotes. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Your double-quotes do -- literally -- nothing at all, remove them.
|
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Is 5 not the right answer?
|
|
#4
|
|||
|
|||
|
yes it is. and i got it from using the double quotes.
---------- Post updated at 11:10 AM ---------- Previous update was at 11:09 AM ---------- if the double quotes are meaningless, please provide a better suggestion. |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
What do you get? I get: Code:
$ echo "2012-12-26--14.8224 2012-12-27--14.2898 2012-12-28--14.9180 2012-12-29--13.3637 2012-12-30--13.7091" | wc -w
5
$ echo 2012-12-26--14.8224 2012-12-27--14.2898 2012-12-28--14.9180 2012-12-29--13.3637 2012-12-30--13.7091 | wc -w
5I agree with Corona688 that using double double quotes is meaningless.. |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Quote:
The real question is, what was happening in the first place to make a wrong answer when your quotes make no difference? Either your data or your program must have been unexpectedly different in some way. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl code to check date and check files in particular dir | ajaypatil_am | Shell Programming and Scripting | 1 | 07-05-2012 08:29 AM |
| check in and check out comments | saku | Shell Programming and Scripting | 0 | 02-08-2012 02:00 AM |
| Check EOF char in Unix. OR To check file has been received completely from a remote system | alexalex1 | UNIX for Advanced & Expert Users | 5 | 07-22-2010 07:48 PM |
| script to check if another script is running and if so, then sleep for sometime and check again | mathews | Shell Programming and Scripting | 2 | 07-21-2010 11:25 PM |
| Script to check for a file, check for 2hrs. then quit | mmarsh | UNIX for Dummies Questions & Answers | 2 | 09-16-2005 02:46 PM |
|
|