Jump to content

date output [solved]


Recommended Posts

I did this, but it only works on the positioning of the characters of the url you specified. This was for testing, so you could see it works:

 

echo "http://files.ad.nl/strips/image.php?strip=dirkjan&datum=2006-03-11" | cut -c 57-67

 

and the results:

 

[ian@esprit ~]$ cat test
echo "http://files.ad.nl/strips/image.php?strip=dirkjan&datum=2006-03-11" | cut -c 57-67
[ian@esprit ~]$ ./test
2006-03-11

 

Obviously if the url length changes, you need to change the digits at the end which specify cutting characters from position 57 to 67. Or find a way of getting cut to calculate the position of the date based on a field character. See this example for pulling uid from /etc/passwd:

 

[ian@esprit ~]$ cat /etc/passwd | grep ian | cut -f 3 -d :
500

 

you might be able to get the same to work. To get the gid instead of uid, you change the "3" to a "4" and so on for other info. Actually, I just used that too:

 

[ian@esprit ~]$ cat test
echo "http://files.ad.nl/strips/image.php?strip=dirkjan&datum=2006-03-11" | cut -f 3 -d =
[ian@esprit ~]$ ./test
2006-03-11

 

and works, as there are two equals signs splitting it into 3 parts, so choosing the 3rd part, using delimeter =. If a third equals sign was listed, then the date would be in the fourth field part, and therefore having to change the "3" to a "4" to get it to work.

Link to comment
Share on other sites

date +%Y-%m-%d

 

I tried that first because it looked the easist and what do you know... it worked. :D

 

the script now looks like:

 

#! /bin/bash

url="http://files.ad.nl/strips/image.php?strip=dirkjan&datum=$(date +%Y-%m-%d)"

imgname=/home/xxxxx/tmp/dirkjan.jpg

wget -qO $imgname "$url"

echo -n "$imgname"

 

Because komics uses kuickshow to show the actual comic and it needs for the file to have an extension. It's working again now so I hope the newspaper will keep this adress. I hate it when they change things.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...