bash随笔

发布时间 2023-06-30 22:19:18作者: huh&uh

bash

for i in `ls *.txt`; do mv $i ${i%.txt}.md; done

bash

echo '127.0.0.1' | sed -n '/[0-9]\+.[0-9]\+.[0-9]\+.[0-9]\+/p'

bash

find / | grep -vE "要搜的字符" nasm .txt gcc 

bash

awk '{ sum += $1 }; END { print sum }' filename
awk -F: '{ print $1 }' | cat /etc/passwd

bash

for i in `curl <url> | tr -cs '[:alnum:]' ' ' | sort -u`;
do 
	echo $i >> <filename>;
done

bash

url="<url>"
curl url | grep -Eo 'href="[^\"]+"' | sed 's/href=//; s/\"//g' | while read line; do
  if [[ $line == /* ]] || [[ $line =~ ^https?:// ]]; then
    echo $line
  else
    echo "${url}${line}"
  fi
done