Skip to content

Latest commit

 

History

History
70 lines (46 loc) · 1.79 KB

linux-shell.adoc

File metadata and controls

70 lines (46 loc) · 1.79 KB

쉘 안에서 현재 경로

#!/bin/sh
BASEDIR=`dirname $0`
echo $BASEDIR
cd $BASEDIR

언제나 절대경로로 하려면

$(cd dirname $0 && pwd)

파일명

find . -type f -name "*Controller.java" -printf "%f\n" | sort | uniq | awk '{print "- [ ] " $1}'

find / -name "sysinfo.html"

grep "sysinfo.html" *|awk '{print $1}'

내용

# 찾기
find /. -name "*" | xargs grep -i "benelog"

find /. -name "*" -print -exec grep "benelog" {} \;

find /. -name "*" -print | wc -l


# sub directory안의 파일 내용 중에 문자열 대체하기
find ./ -type f -exec sed -i -e 's/assets-cdn.github.com/github.githubassets.com/g' {} \;

용량과 업로드일자

find ./ -mtime -30 -size +1024k -ls find /. -name "StringCleaner.java" | xargs du -b

날짜

  • echo $(date '+%y%m%d') → 060728

  • echo $(date '+%Y%m%d') → 20060728

  • echo $(date '+%Y%m%d_%H%M%S') → 20060728_170000

  • echo $(date +"%Y%m%d%H%M%S")

  • echo $(date +%Y%m%d --date '1 day ago')

파일명 일괄 변경

_를 -로
for i in *_*;do mv $i ${i//"_"/"-"};done