
RHEL에 NTFS 디스크를 연결하고 있습니다.
마운트하려면 나중에 명령에서 사용할 파티션 이름을 알아야 합니다 mount
.
이름 이 포함된 문자열을 가져와야 합니다 . 해당 문자열 이 무엇에 속하는지 Device
알아야 합니다 .System
fdisk -l
이 명령은 다음을 반환합니다.
Disk /dev/sdb: 15.0 GB, 15032385536 bytes, 29360128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xdf77eb64
Device Boot Start End Blocks Id System
/dev/sdb1 128 29358079 14678976 83 Linux
Disk /dev/sda: 31.5 GB, 31457280000 bytes, 61440000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x000c46d3
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 61439999 30206976 83 Linux
Disk /dev/sdc: 1862 MB, 1862270976 bytes, 3637248 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xf9fa7844
Device Boot Start End Blocks Id System
/dev/sdc1 128 3635199 1817536 7 HPFS/NTFS/exFAT
나는 string 을 얻고 싶습니다 /dev/sdc1
. 그 시스템이 다음과 같기 때문입니다.HPFS/NTFS/exFAT
Device
형식이 지정되어야 한다는 것을 알면서 문자열을 어떻게 얻을 수 있습니까 HPFS/NTFS/exFAT
?
답변1
좋습니다. 명령 출력에서 문자열을 추출하려고 합니다. UNIX가 선호하는 작고 간단한 명령 체인을 다음과 같은 방식으로 사용하십시오.
fdisk -l | grep NTFS | cut -f 1 -d " "
fdisk
아시다시피 일반적인 정보를 출력합니다. |
화면이 아닌 다음 명령에 출력을 제공한다는 의미의 파이프 기호입니다. grep
그런 다음 NTFS가 포함된 줄만 추출하고 cut
줄의 첫 번째 필드를 추출합니다. 이 경우 열 구분 기호는 공백입니다.