티스토리 뷰
Variable Attributes(typeset)
typse -L10 var_name
or
typeset -L10 var_name="value string"
Attribute/typeset option/sample
Left Justify -L "string "
Right Justify -R " string"
Lower Case -l "string"
Upper Case -u "STRING"
Display Formatted Data
Formatted: print "$var"
Unformatted: print $var
Conversion: printf "%.10s" "$var" //built-in cmd인 print와 다르게 external cmd인 printf는 c언어의 printf와 같다. man printf 커맨드로 메뉴얼 페이지에서 확인
#! Formatted, Unformatted의 예..
$ var='this is a test string'
$ print $var
this is a test string
$ print "$var"
this is a test string
$ var='this is a test string'
$ print $var
this is a test string //여러 공백들이 하나로 대체된다.
$ print "$var"
this is a test string //의도한 string이 출력된다
$ cp file1 file2 //shell은 공백의 중복을 하나의 공백으로 대체하므로 이러한 명령도 의도대로 잘 사용된다. 물론 의도한 공백을 넣은 string을 출력할 땐
#! printf의 예...
#!/usr/bin/sh
# printf.sh
# conversion at output time
var="posix shell programming"
# notice, printf does not produce an automatic linefeed
printf "%.5s" "$var"
# output is converted to a 5 character string
# output: "posix"$
printf "%30s" "$var"
# output is extended to right justified 30 char string
# no linefeed before the next shell prompt '$'
# output: "posix shell programming "$
printf "%-30s" "$var"
# output is extended to left justified 30 char string
# output: " posix shell programming"$
printf "\n%.11s\n" "$var"
# output is trimmed to 11 characters, linefeed added
printf "Interpreter:%11s\n" "$var"
# output includes some added text, then 11 characters
exit
'IoT 과정' 카테고리의 다른 글
Branches and Logic Testing (0) | 2017.07.06 |
---|---|
Shell Arithmetic (0) | 2017.07.06 |
User Input (0) | 2017.07.05 |
Variable (0) | 2017.07.05 |
Shell Scripting (0) | 2017.07.05 |
- Total
- Today
- Yesterday
- Propositional and Predicate Logic
- paul wilton
- 최단경로 알고리즘
- flutter
- arena simulation
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- 백준
- 시뮬레이션
- Arena
- 그라파나
- beginning javascript
- Discrete Mathematics
- 이산수학
- 자바스크립트
- javascript
- 이산 수학
- 대규모 시스템 설계 기초
- rosen
- 데이터 중심 애플리케이션 설계
- 로젠
- 엄청난 인내심과 시뮬레이션을 위한 아레나 툴
- 명제논리
- 아레나 시뮬레이션
- 조합 코딩
- 자바스크립트 예제
- 아레나
- 아레나시뮬레이션
- Simulation
- grafana cloud
- Trie
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |