LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-29-2014, 11:21 AM   #31
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,243

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684

Like all variables the $ will return the value. Seeing as you do not wish to assign it to anything, just remove the $ and all is good with the world. No need for additional items like the colon.

Nice alternative to go with date and as a solution has been presented, here is another:
Code:
#!/bin/bash

while read -a vals
do
	[[ ${vals[5]} == 13 ]] && ((cnt++))
	[[ ${vals[12]} == 13 ]] && ((cnt++))
	[[ ${vals[19]} == 13 ]] && ((cnt++))
done< <(cal -y $1)

echo "Number of black fridays: $cnt"
Again no error checking but here if you omit the date all together it will use the current year
 
Old 05-01-2014, 08:10 PM   #32
michaelgg13
LQ Newbie
 
Registered: Apr 2014
Posts: 11

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by UNIXnub22 View Post
michaelgg13: We must be in the same class
you mean kads? haha
 
Old 05-01-2014, 08:50 PM   #33
UNIXnub22
LQ Newbie
 
Registered: Apr 2014
Location: New York
Posts: 8

Rep: Reputation: Disabled
Yes! Haha. Who is this?
 
Old 07-31-2014, 01:39 PM   #34
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Code:
#!/bin/bash
Year="$1"
unset Friday13
for Mth in {01..12};do
    WM="$(date +"%A %B" --date=${Year}-${Mth}-13)"
    [[ $WM =~ ^Friday ]] && Friday13+=(${WM/Friday /})
done
echo "${#Friday13[@]} Friday the 13ths in year $Year"
echo "${Friday13[@]}"

All detailed in these

http://www.tldp.org/LDP/Bash-Beginners-Guide/html/
http://www.tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/BashGuide
http://www.gnu.org/software/bash/manual/bashref.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Friday the 13th Massive Upgrade willysr Slackware 232 10-18-2012 08:15 AM
bash script to count number of lines with a specific property7 hhamid Programming 10 08-13-2010 02:35 AM
Bash: Counting the number of character occurences in a variable basildon Linux - Newbie 3 09-22-2008 11:11 AM
C++ STL count() number of substring occurences... nyk Programming 4 06-25-2004 08:12 AM


All times are GMT -5. The time now is 10:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration