Windows에서는 탐색기를 열고 열을 추가하여 파일에 대한 추가 정보를 볼 수 있습니다. 예를 들어 아래 이미지에서 회사, 저작권 및 설명에 대한 열을 추가했습니다.
Linux (Ubuntu 12.04 LTS)를 실행하는 시스템의 명령 줄을 통해이 정보를 얻을 수있는 방법이 있는지 알아야합니다. 나는 사용할 수있다. 현 그리고 회사 이름에 grep을하고 그것을 보았습니다. 그러나 나는 이미 회사 이름을 알고 있다고 가정합니다. 나는 “회사”에 대해 grep 할 수 없으며 같은 또는 다음 줄에 회사 이름을 반환해야합니다.
답변
모든 정보를 얻을 수는 없습니다. ls
.
몇 가지 명령이 필요합니다.
-
이름 :
ls
-
소유자 :
ls -ld <filename> | cut -f3 -d' '
예 :
root
-
수정 된 날짜 :
ls -ld <filename> | awk '{print $6" "$7}'
예 :
2012-03-02 06:56
(용도
stat <filename>
날짜가 액세스되고 변경된 경우). -
유형 :
file <filename>
예 :
/lib/libiw.so.30: ELF 32-bit LSB shared object, Intel 80386 (...)
-
크기 :
ls -hld <filename> | cut -f5 -d' '
예 :
34K
-
태그 : N / A
-
회사 :
apt-cache show $(dpkg -S <filename> | cut -f1 -d:) | grep Origin
예 :
Origin: Ubuntu
(.rpm 기반 시스템에서이 정보는에서 찾을 수 있습니다.
rpm -q -i -f <filename>
) -
저작권 :
cat /usr/share/doc/$(dpkg -S <filename> | cut -f1 -d:)/copyright 2>/dev/null || echo 'No copyright information'
예 :
(...) Copyright: Commercial (...)
(.rpm 기반 시스템에서이 정보는에서 찾을 수 있습니다.
rpm -q -i -f <filename>
) -
기술 :
apt-cache show $(dpkg -S <filename> | cut -f1 -d:) | fgrep 'Description' | fgrep -v Description-md5
예 :
Description-en: Filesystem in Userspace (library)
(.rpm 기반 시스템에서이 정보는에서 찾을 수 있습니다.
rpm -q -i -f <filename>
) -
장황한 설명 :
apt-cache show $(dpkg -S <filename> | cut -f1 -d:) | egrep -v '^[^ ]'
예 :
GNU findutils provides utilities to find files meeting specified
criteria and perform various actions on the files which are found.
This package contains 'find' and 'xargs'; however, 'locate' has
been split off into a separate package.(.rpm 기반 시스템에서이 정보는에서 찾을 수 있습니다.
rpm -q -i -f <filename>
)
위의 정보를 많이 제공하는 Ubuntu의 쉘 기능은 매우 빠르며 더러운 것입니다.
function lsw { filename=$1; ( echo "XXNameXXOwnerXXDate ModifiedXXTypeXXSizeXXCompanyXXDescription"; ( echo XX$filename; echo -n XX; ls -dl $filename | cut -f3 -d' '; echo -n XX; ls -dl $filename | awk '{print $6" "$7}'; echo -n XX; file $filename | cut -f2 -d: | cut -f1 -d,; echo -n XX; ls -hld $filename| cut -f5 -d' '; echo -n XX; apt-cache show $(dpkg -S $filename 2>/dev/null| cut -f1 -d:) 2>/dev/null| egrep 'Origin:|Section:' | tail -n 1 | cut -f2 -d:; echo -n XX; apt-cache show $(dpkg -S $filename 2>/dev/null| cut -f1 -d:) 2>/dev/null| fgrep 'Description' | fgrep -v Description-md5 | cut -f2 -d:) | tr '\n' ' '; echo ) | column -t -s XX; }
몇 가지 예 :
$ lsw /home/jaume
Name Owner Date Modified Type Size Company Description
/home/jaume jaume 2013-02-19 22:01 directory 4.0K
$ lsw /opt/ibm/notes/notes
Name Owner Date Modified Type Size Company Description
/opt/ibm/notes/notes root 2012-12-08 08:47 ELF 32-bit LSB executable 47K IBM IBM Notes
$ lsw /lib/libfuse.so.2
Name Owner Date Modified Type Size Company Description
/lib/libfuse.so.2 root 2012-03-02 16:33 symbolic link to `libfuse.so.2.8.6' 16 Ubuntu Filesystem in Userspace (library)