Last active
July 17, 2018 03:13
-
-
Save mulderu/fccbf997552ff3fd660d11dbd954e62e to your computer and use it in GitHub Desktop.
bash util
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# locale setup | |
sudo locale-gen "en_US.UTF-8" | |
sudo locale-gen "ko_KR.UTF-8" | |
#.bashrc | |
export LANG="ko_KR.UTF-8" | |
export LC_ALL="ko_KR.UTF-8" | |
# multiple fname pattern find | |
find /home/mulder/Downloads/phone_0 -name "*.jpg" -o -name "*.png" | |
#!/bin/bash | |
# Cleans directory from cvs dir/files. | |
# http://snippets.dzone.com/posts/show/934 | |
# kill process by grep | |
ps -ef | grep skess | grep -v grep | awk '{print $2}' | xargs kill | |
find "$1" -name 'CVS' -exec rm -rf '{}' \; -print | |
# Generate fake file with a specific size (useful for uploads) | |
head -c 3000000 /dev/urandom > upload_test_3MB.zip | |
# Extracts count per page name in an access_log Apache file | |
awk -F'[ "]+' '{ pagecount[$7]++ } END { for (i in pagecount) { printf "%d - %15s\n", pagecount[i], i } }' access_log | |
# Get only response headers of a webpage. | |
curl -s -D- -onul "http://www.google.it" | |
# Fetch a webpage, returning only its body. | |
wget -qO- "http://www.google.it" | |
# Search files modified on the latest 2 days | |
find . -mtime -2 | |
# Copy last command with its output. | |
# Usage: | |
# $ <COMMAND> | pbcopy | |
# $ pbcopylast | |
function pbcopylast { | |
last=$(history 2 | head -1) | |
( | |
echo -n $last | sed "s/^[ ]*[0-9]*[ ]*/\$ /g" | sed "s/[ ]*\|[ ]*pbcopy$//g" | |
echo "" | |
pbpaste | |
) | pbcopy | |
} | |
#-------------------------------------------------------------------- | |
# make last 500 files | |
# | |
ls -tlr *.{jpg,png} | tail -500 > ls.txt | |
# | |
rm -rf updated | |
mkdir -p updated | |
cut -c47-80 ls.txt | awk '{print "cp " $1 " updated" }' > cp-shell | |
sh cp-shell | |
tar czf updated.tgz updated | |
#-------------------------------------------------------------------- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-- BASH DATE
DATE=
date +%Y-%m-%d
DATE=
date '+%Y-%m-%d %H:%M:%S'