Showing posts with label UNIX. Show all posts
Showing posts with label UNIX. Show all posts

Thursday, July 7, 2016

chmod 를 recursive 하게 적용하는 법

폴더 밑의 permission 을 recursive 하게 바꿔주려면
chmod -R
을 쓰면 됨. 예를 들어 폴더 밑의 모든 파일들의 퍼미션을 read only 로 해주려면
chmod -R -w foldername
와 같이 해줌. 그러면 모두 읽기 전용이 됨

Tuesday, June 2, 2015

OS X에서 셸 스크립트를 더블클릭으로 실행하게 하는 법법

Shell Script 파일의 확장자를 .command 로 해준다.
(밑의 출처에는 chmod a+x scriptname 해주는 방법만 소개한 사람이 있는데 이 방법만으론 안됨)
키워드 : extension
출처 : How to run a shell script in OS X by double-clicking?

Sunday, May 31, 2015

os x terminal 에서 change directory 간편하게 하는 법

terminal 로 폴더를 command 누르고 drag 하면 그 폴더로 cd 즉 change directory 가 된다.
키워드 : change, current, folder

Saturday, April 19, 2014

파일명 list 얻는 법

ls 를 recursive 하게 하는 unix 명령어 사용한다
ls -LR | grep .txt
ls -LR | grep .txt > multTable.txt
키워드 : Filename, enumerate, 리스트

Wednesday, January 9, 2013

Perl 내부에서 bash script 호출하는 법

다음과 같이 하면 된다.
system('ls -l');
키워드 : call, 안쪽, 시스템, 유닉스 명령어, UNIX command

Saturday, January 5, 2013

UNIX pipes and redirects

The Unix Command Line: Pipes and Redirects ... tr, sort, uniq, comm 으로 사용한 예
 tr 'A-Z' 'a-z' <fnord.txt | tr -cs 'a-z' '\n' | sort | uniq | comm -23 - /usr/share/dict/words  

Pipes and Filters ... cat, wc, sed, awk, grep 으로 사용한 예
 $ cat apple.txt  
 core  
 worm seed  
 jewel  
 $ cat apple.txt | sed -e "s/e/WWW/"  
 corWWW  
 worm sWWWed  
 jWWWwel  
 $ cat apple.txt | sed -e "s/e/J/g"  
 corJ  
 worm sJJd  
 jJwJl  
 $ cat basket.txt  
 Layer1 = cloth  
 Layer2 = strawberries  
 Layer3 = fish  
 Layer4 = chocolate  
 Layer5 = punch cards  
 $ cat basket.txt | awk -F= '{print $1}'  
 Layer1  
 Layer2  
 Layer3  
 Layer4  
 Layer5            
 $ cat basket.txt | awk -F= '{print "HAS: " $2}'  
 HAS: cloth  
 HAS: strawberries  
 HAS: fish  
 HAS: chocolate  
 HAS: punch cards      

Unix - Pipes and Filters ... ls, grep, sort 로 사용한 예
 $ls -l | grep "Aug"  
 -rw-rw-rw-  1 john doc   11008 Aug 6 14:10 ch02  
 -rw-rw-rw-  1 john doc   8515 Aug 6 15:30 ch07  
 -rw-rw-r--  1 john doc   2488 Aug 15 10:51 intro  
 -rw-rw-r--  1 carol doc   1605 Aug 23 07:35 macros  
 $ls -l | grep "Aug" | sort +4n  
 -rw-rw-r-- 1 carol doc   1605 Aug 23 07:35 macros  
 -rw-rw-r-- 1 john doc   2488 Aug 15 10:51 intro  
 -rw-rw-rw- 1 john doc   8515 Aug 6 15:30 ch07  
 -rw-rw-rw- 1 john doc   11008 Aug 6 14:10 ch02  

Bash Reference Manual

Bash Reference Manual

which, whereis

Linux / UNIX: Command Not Found Error and Solution

bash 에서 while 문으로 command line argument 를 loop 하는 법

 for num  
 do  
   echo $num  
 done  
for num; do ...
for num in "$@"; do ... 는 동일.
How to loop through arguments in Bash ($1 $2 $3 and so forth)?

echo 를 newline 안하고 하는 방법

how do I echo $something >> file.txt without carriage return?
Bash Script, no new line for echo command
검색어 : bash echo without newline

bash script 의 while loop

Bash Guide for Beginners - Chapter 9. Repetitive tasks - The while loop
Bash Guide for Beginners - Chapter 9. Repetitive tasks - The for loop

Thursday, January 3, 2013

bash shell 의 if statement

 if [ $# -eq 0 ]  
 then  
      echo " is Zero"  
 else  
      echo " NOT Zero."  
      echo $#  
 fi  
두줄을 한줄에 쓰려면 다음과 같이 한다.
 if [ $# -eq 0 ]; then  
      echo " is Zero"  
 else  
      echo " NOT Zero."  
      echo $#  
 fi  
if [ $# -eq 0 ] 를 if [ $# -eq 0] 와 같이 쓰면 에러가 난다.

Wednesday, January 2, 2013

Saturday, December 29, 2012

OS X terminal 에서 화면 깨끗이 clear 하기

Command + K 하면 된다.
clear 명령을 쓰면 기존의 명령어는 스크롤해 올라가면 그냥 위쪽에 남아 있다.
키워드 : 터미널

Thursday, December 27, 2012

OS X terminal 색상 및 폰트 조절법

  1. terminal 에서 command + , 로 Preferences 창 띄우고
  2. Settings 탭으로 들어간다.
  3. Text 탭에서 Change... 버튼으로 Font 를 세팅해준다 (디폴트 크기는 너무 작으므로 Courier 14 pt 정도가 적절)
  4. 여기서 좌측을 보면 몇가지 종류의 스킨이 보인다.
  5. Startup 탭으로 들어가면 스킨을 고를 수 있다. On startup, open : New window with settings : 항목에서 선택해주면 된다. Novel 등이 읽기 편하다. 여기서 고른 것은 Settings tab 에서 "Startup" 으로 표시된다.
  6. New windows open with : 와 New tabs open with : 도 same settings, Same Working Directory 로 바꿔주면 편하다.
키워드 : skin, color, 색깔

Tuesday, December 18, 2012

bash 스크립트 내에서 스크립트 자신의 폴더 알아내는 법

다음과 같이 하면 된다.

DIR=$( cd "$( dirname "$0" )" && pwd )
echo $DIR

출처 : Can a Bash script tell what directory it's stored in?
키워드 : Perl, 디렉토리, folder

Saturday, December 1, 2012

OS X Terminal 의 man page 에서 나가는 법

q 를 누르면 된다.
검색어 : os x man exit
레퍼런스 : Mac OS X Terminal - How to get out of 'man'?

Saturday, June 9, 2012

OS X 에서 Terminal 화면을 clear 하는 법

터미널 화면을 깨끗이 지우는 법
Command + K 하면 됨 (Clear Scrollback)

Thursday, December 15, 2011

Windows 에서 unix 명령인 cat 쓰는 법

질문 : 윈도우에서 cat 쓰는 법? (mac os x 에서 split로 나눈 파일을 윈도우에서 cat으로 붙인다거나 할때)
답 : cygwin 을 쓰면 cat을 쓸수 있다고 함 (테스트는 해보지 않았음)
추가 : DOS 명령인 type 을 써도 가능할지? 테스트해보지는 않았음
Combine 2 text files into one
UNIX: cat file1 file2 > file3
DOS: type file1 file2 > file3
DOS: copy file1+file2 file3
인용 : you can install cygwin, then you can have cat, grep, awk, sed, etc. Any command on linux would work on windows.
링크 : Windows 'cat' equivelant
unix 'cat' command in windows?