Entry tags:
Mess with DNS
Julia Evans has built a site to help you play with DNS without messing up stuff in your life that needs to work.
WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser.
find base command, doesn't change . the top directory you're seeking in. Could put a relative or absolute path here. -type f Narrowing down the kind of files you're seeking, in this case to regular files. You could narrow it down in other ways, e.g. -name "*.c" -exec egrep -H "string I'm seeking" {} \; the grep command in question. The only thing I have a very here is the egrep switch (and the string). -H lists filename and the match -l just lists the filename; less informative but cleaner. {} \; is necessary syntax for the exec argument to find.
References 1. http://example.org/lolcats-page-2/ 2. http://example.org/lolcats/lolcat-101.gif 3. http://example.org/lolcats/lolcat-102.gif
The best ping story I've ever heard was told to me at a USENIX conference, where a network administrator with an intermittent Ethernet had linked the ping program to his vocoder program, in essence writing:ping goodhost | sed -e 's/.*/ping/' | vocoder
He wired the vocoder's output into his office stereo and turned up the volume as loud as he could stand. The computer sat there shouting "Ping, ping, ping..." once a second, and he wandered through the building wiggling Ethernet connectors until the sound stopped. And that's how he found the intermittent failure.
#!/bin/bash
# update friendica with bash, vim and curl
# I put this in my path as "friendi.sh"
# by tony baldwn, http://tonybaldwin.me
# on friendica at http://free-haven.org/profile/tony
# released according to the Gnu Public License, v.3
# first, create a post/update
filedate=$(date +%m%d%y%H%M%S)
# if you did not enter text for update, the script asks for it
if [[ $(echo $*) ]]; then
ud="$*"
else
vim $filedate.fpost
ud=$(cat $filedate.fpost)
fi
# now to see if you want to crosspost elsewhere
echo "For the following question regarding crossposting, please enter the number 1 for yes, and 0 for no."
echo "If your friendica has the plugins, and you've configured them, you can crosspost to other blogs and sites."
echo "friendica will even automatically change the bbcode to proper html for you."
echo "would you like to crosspost to "
read -p "statusnet? " snet
read -p "twitter? " twit
read -p "facebook? " fb
read -p "dreamwidth? " dw
read -p "livejournal? " lj
read -p "tumblr? " tum
read -p "posterous? " pos
read -p "wordpress? " wp
# now to authenticate
read -p "Please enter your username: " uname
read -p "Please enter your password: " pwrd
read -p "Enter the domain of your Friendica site (i.e. http://friendica.somesite.net, without trailing /): " url
# and this is the curl command that sends the update to the server
if [[ $(curl -u $uname:$pwrd -d "status=$ud&ljpost_enable=$lj&posterous_enable=$pos&dwpost_enable=$dw&wppost_enable=$wp&tumblr_enable=$tum&facebook_enable=$fb&twitter_enable=$twit&statusnet_enable=$snet&source=friendi.sh" $url/api/statuses/update.xml | grep error) ]]; then
# what does the server say?
echo "Error"
else
echo "Success!"
echo $ud
fi
grep
command into IRC or IM, and don't want each match on a separate line. Fortunately, it's easy to convert it to a comma-separated list instead - simply pipe the output through xargs echo | sed 's/ /, /g'
. So, for example, instead of:Sophie@Sophie-Laptop:~/primtionary$ grep cuddle american-english-insane
cuddle
cuddleable
cuddled
cuddler
cuddlers
cuddles
cuddlesome
scuddle
scuddled
scuddles
upscuddle
Sophie@Sophie-Laptop:~/primtionary$ grep cuddle american-english-insane | xargs echo | sed 's/ /, /g'
cuddle, cuddleable, cuddled, cuddler, cuddlers, cuddles, cuddlesome, scuddle, scuddled, scuddles, upscuddle
sort
and then piping the output of that through uniq
, you can just use sort -u
, which will do both operations at once.sort | uniq -c | sort -n
to sort by the number of times a line appears, but it's still a nice tip. :)
tara_hanoi@tara_babel:/export/home/sketchy$ wget --max-redirect=0 http://t.co/8xED8dz
--2011-07-25 16:01:10-- http://t.co/8xED8dz
Resolving t.co... 199.59.148.12
Connecting to t.co|199.59.148.12|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://bit.ly/guxtdh [following]
0 redirections exceeded.
tara_hanoi@tara_babel:/export/home/sketchy$ wget --max-redirect=1 http://t.co/8xED8dz
--2011-07-25 16:03:50-- http://t.co/8xED8dz
Resolving t.co... 199.59.148.12
Connecting to t.co|199.59.148.12|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://bit.ly/guxtdh [following]
--2011-07-25 16:03:51-- http://bit.ly/guxtdh
Resolving bit.ly... 168.143.172.53, 2001:418:e801::12:1, 2001:418:e801::15:1, ...
Connecting to bit.ly|168.143.172.53|:80... connected.
HTTP request sent, awaiting response... 301 Moved
Location: http://tara-hanoi.dreamwidth.org/1508.html [following]
1 redirections exceeded.
sed -i 's/\r//' $file_name
perl -pi -e 's/\r\n/\n/g' $file_name
command 1 | command2
command2
doesn't allow reading from standard input, and only supports filenames? How can you do this without writing to a file?<(command)
syntax. For example, the above command can be written:command2 <(command1)
command1
in a subshell, and at the same time, call command2
with a file descriptor looking something like /dev/fd/63
. When command2
reads from that, it'll get the output of command1
.diff -u <(sort filea.txt) <(sort fileb.txt)
rev <(echo wheeness; sleep 2; echo blarg)
xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
ls: cannot access /home/sophie/directory: No such file or directory
ls: cannot access with: No such file or directory
ls: cannot access spaces: No such file or directory
ls: cannot access in/blah.txt: No such file or directory
-d"\n"
switch before the command you want xargs to execute. This tells xargs that you don't want xargs to mess with your input at all except to treat newline characters as delimiters. This time, you should find that both apostrophes and spaces are accepted properly.