Macbook 시스템 분석기 포맷됨

Macbook 시스템 분석기 포맷됨

system_profilerMacbook 터미널 명령에서 생성된 출력의 형식을 지정 하고 행 값을 동일한 애플리케이션 아래의 열로 바꾸고 싶습니다 .

다음은 파일의 일부입니다.

파이어폭스 브라우저:

  Version: 32.0.3
  Obtained from: Identified Developer
  Last Modified: 28/09/2014 18:23
  Kind: Intel
  64-Bit (Intel): Yes
  Signed by: Developer ID Application: Mozilla Corporation, Developer ID Certification
  Location: /Applications/Firefox.app
  Get Info String: Firefox 32.0.3

Calendar:

  Version: 7.0
  Obtained from: Apple
  Last Modified: 18/03/2014 06:58
  Kind: Intel
  64-Bit (Intel): Yes
  Location: /Applications/Calendar.app

...그리고 출력이 다음과 같기를 원합니다.

1

노트:

  1. 모든 지원서에 모든 필드가 채워지는 것은 아닙니다.
  2. 이러한 메시지는 최대 8개까지 있습니다(Firefox 응용 프로그램 아래 전체 세트 참조).
  3. 각 애플리케이션 정보 그룹 사이의 선행 패딩 공백 및 개행 문자

답변1

awk -F: ' # set fields separator to :
$1!="" && $2==""{i++;NAME[i]=$1} # if 1st field without second it is app.name
$2!=""{HEAD[$1]=1;DATA[NAME[i],$1]=$2 $3} # put variables name into array
#+ put variables into 2-dimention array app.name,var.name  
END{
printf("%s:","Application"); # first column in header
for (n in HEAD) printf("%s:",n); # print all var.name as header separated by :
print ""; # finish line by newline
for(i in NAME){ # for each app.name
  printf("%s:",NAME[i]); # print app.name
  for (n in HEAD) printf("%s:", DATA[NAME[i],n]); # print each variables corresponding to app.name
  print ""; # finish line by newline
  }
}' data.file | sed -E 's/:\s*/:/g' | column -s: -tn

sed 다음 공백을 모두 제거하세요.:

column텍스트 열 서식 지정

관련 정보