mirror of
https://github.com/thewesker/greptweet.git
synced 2025-12-21 04:31:05 -05:00
19 lines
400 B
Bash
Executable File
19 lines
400 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# vim: set ts=4 sw=4
|
|
|
|
test -s $1 || exit
|
|
test ${1##*.} = 'txt' || exit
|
|
|
|
temp=$(mktemp "$1.XXXX")
|
|
|
|
IFS='|'
|
|
while read -r id date text
|
|
do
|
|
url=$(echo $text | grep --only-matching --perl-regexp "http(s?):\/\/[^ \"\(\)\<\>]*")
|
|
expandedURL=$(curl "$url" -m5 -s -L -I -o /dev/null -w '%{url_effective}')
|
|
t=${text/$url/$expandedURL}
|
|
echo "$id|$date|$t"
|
|
done < $1 > $temp
|
|
|
|
mv $temp $1
|