월별 글 목록: 2015년 12월월

bash shell 매개변수 확장

매개 변수 확장(Parameter Expansion)

아래 예를 테스트하기 위한 변수: string="abc-efg-123-abc"

문자 설명
${변수} $변수와 동일하지만 {} 사용해야만 동작하는 것들이 있음(예: echo ${string})
${변수:위치} 위치 다음부터 문자열 추출(예: echo ${string:4})
${변수:위치:길이} 위치 다음부터 지정한 길이 만큼의 문자열 추출(예: echo ${string:4:3})
${변수:-단어} 변수 미선언 혹은 NULL일때 기본값 지정, 위치 매개 변수는 사용 불가(예: echo ${string:-HELLO})
${변수-단어} 변수 미선언시만 기본값 지정, 위치 매개 변수는 사용 불가(예: echo ${string-HELLO})
${변수:=단어} 변수 미선언 혹은 NULL일때 기본값 지정, 위치 매개 변수 사용 가능(예: echo ${string:=HELLO})
${변수=단어} 변수 미선언시만 기본값 지정, 위치 매개 변수 사용 가능(예: echo ${string=HELLO})
${변수:?단어} 변수 미선언 혹은 NULL일때 단어 출력 후 스크립트 종료,(예: echo ${string:?HELLO})
${변수?단어} 변수 미선언시만 단어 출력 후 스크립트 종료(예: echo ${string?HELLO})
${변수:+단어} 변수 선언시만 단어 사용(예: echo ${string:+HELLO})
${변수+단어} 변수 선언 혹은 NULL일때 단어 사용(예: echo ${string+HELLO})
${#변수} 문자열 길이(예: echo ${#string})
${변수#단어} 변수의 앞부분부터 짧게 일치한 단어 삭제(예: echo ${string#a*b})
${변수##단어} 변수의 앞부분부터 길게 일치한 단어 삭제(예: echo ${string##a*b})
${변수%단어} 변수의 뒷부분부터 짧게 일치한 단어 삭제(예: echo ${string%b*c})
${변수%%단어} 변수의 뒷부분부터 길게 일치한 단어 삭제(예: echo ${string%%b*c})
${변수/찾는단어/변경단어} 처음 일치한 단어를 변경(예: echo ${string/abc/HELLO})
${변수//찾는단어/변경단어} 일치하는 모든 단어를 변경(예: echo ${string//abc/HELLO})
${변수/#찾는단어/변경단어} 앞부분이 일치하면 변경(예: echo ${string/#abc/HELLO})
${변수/%찾는단어/변경단어} 뒷부분이 일치하면 변경(예: echo ${string/%abc/HELLO})
${!단어*}, ${!단어@} 선언된 변수중에서 단어가 포함된 변수 명 추출(예: echo ${!string*}, echo ${!string@})

force10 포트 미러링

Configure Port Monitor Session

Command Purpose
Force10# configure Enter configuration mode.
Force10(conf)# interface te 0/2 Enter the destination port to be used for monitor session. Confirm that it has no configuration.
Force10(conf-if-te-0/2)# no ip address Remove any ip address that may be configured.
Force10(conf-if-te-0/2)# no shutdown Enable the port.
Force10(conf-if-te-0/2)#exit Leave the destination port interface.
Force10(conf)# monitor session 0 Set up and identify the session number. Range 0 – 65535.
Force10(conf-mon-sess-0)#source te 0/1 destination te 0/2 direction both Set the source (the port you want to monitor). Set the destination (the port where you send the monitored packets). Set the direction (Both/Rx/Tx).

Verify Port Monitor Session

Force10#show monitor session 0
SessID Source Destination Dir Mode Source IP Dest IP
—— —— ———– — —- ——— ——–
0 Te 0/1 Te 0/2 both Port N/A N/A