- Сейчас я пытаюсь вывести LS с заголовком, чтобы предоставить дополнительную информацию о том, что содержится в каждом столбце
- Я использую AWK для форматирования LS с вкладками между каждым столбцом, чтобы сделать его более привлекательно
- Я хочу получить все столбцы, чтобы получить даже длинные имена файлов, et c
Когда я делаю это с помощью for l oop вывод сильно меняется по сравнению с тем, когда я вручную перечисляю большое количество столбцов
Я пробовал делать это из 9 - NF и 9 - 100, но проблема одинакова независимо от
- Я считаю, что проблема где-то в l oop Я просто могу указать свою ошибку
Команда, которая выводит нормально (но не компенсирует все столбцы):
printf "Permissions | Link Count | Owner | Group | Size | Date | Time | Name |\n Size " && ls --color=always --human-readable -S -l -a|awk '{print $1,"\t",$2,"\t",$3,"\t",$4,"\t",$5,"\t",$6,"\t",$7,"\t",$8,"\t",$9,$10,$11,$12,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29}'
Вывод:
frog@gamingrig-popos:~$ printf "Permissions | Link Count | Owner | Group | Size | Date | Time | Name |\n Size " && ls --color=always --human-readable -S -l -a|awk '{print $1,"\t",$2,"\t",$3,"\t",$4,"\t",$5,"\t",$6,"\t",$7,"\t",$8,"\t",$9,$10,$11,$12,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29}'
Permissions | Link Count | Owner | Group | Size | Date | Time | Name |
Size total 216K
-rw------- 1 frog frog 24K May 5 21:46 .bash_history
-rw------- 1 frog frog 6.6K Mar 29 20:28 .xsession-errors
drwxr-xr-x 37 frog frog 4.0K May 6 19:06 .
drwxr-xr-x 3 root root 4.0K Feb 17 16:52 ..
drwx------ 23 frog frog 4.0K May 6 14:16 .cache
drwx------ 44 frog frog 4.0K May 6 19:39 .config
drwxr-xr-x 2 frog frog 4.0K Feb 19 21:31 Desktop
drwxr-xr-x 4 frog frog 4.0K Mar 27 18:26 Documents
drwxr-xr-x 7 frog frog 4.0K May 4 12:45 Downloads
drwxr-xr-x 7 frog frog 4.0K Mar 22 17:33 .ftblauncher
drwx------ 2 frog frog 4.0K Feb 25 20:48 .GameGuide
drwx------ 2 frog frog 4.0K Feb 28 22:21 .gconf
drwx------ 3 frog frog 4.0K Feb 28 20:57 .gdfuse
drwx------ 3 frog frog 4.0K Feb 17 17:14 .gnome
drwx------ 3 frog frog 4.0K Feb 17 17:13 .gnupg
drwxr-xr-x 2 frog frog 4.0K Feb 28 20:57 GoogleDrive
drwxr-xr-x 3 frog frog 4.0K Mar 22 16:34 .java
drwxrwxr-x 5 frog frog 4.0K Mar 15 19:36 .local
drwxr-xr-x 13 frog frog 4.0K Mar 24 00:07 .minecraft
drwx------ 6 frog frog 4.0K Feb 24 19:32 .mozilla
drwxr-xr-x 2 frog frog 4.0K Feb 17 16:52 Music
drwx------ 4 frog frog 4.0K Feb 19 22:17 .nv
drwxr-xr-x 5 frog frog 4.0K Feb 17 20:50 .paradoxlauncher
drwxr-xr-x 2 frog frog 4.0K Apr 30 19:39 Pictures
drwx------ 3 frog frog 4.0K Feb 17 17:14 .pki
drwxr-xr-x 2 frog frog 4.0K Feb 17 16:52 Public
drwx------ 2 frog frog 4.0K Feb 25 20:48 .QtWebEngineProcess
drwxr-xr-x 5 frog frog 4.0K May 6 18:31 Scripts
drwx------ 2 frog frog 4.0K Apr 8 20:36 .ssh
drwxr-xr-x 3 frog frog 4.0K Feb 17 17:41 Steam
drwxr-xr-x 3 frog frog 4.0K May 6 14:39 .steam
drwxr-xr-x 2 frog frog 4.0K Feb 17 16:52 Templates
drwxr-xr-x 2 frog frog 4.0K May 6 18:45 Test Dir
drwxr-xr-x 2 frog frog 4.0K May 6 18:48 Test Dir 1
drwx------ 6 frog frog 4.0K Feb 17 17:47 .thunderbird
drwxr-xr-x 3 frog frog 4.0K Apr 29 18:43 .var
drwxr-xr-x 2 frog frog 4.0K Feb 17 16:52 Videos
drwxr-xr-x 2 frog frog 4.0K Apr 17 19:56 .vnc
drwxr-xr-x 4 frog frog 4.0K May 3 15:38 .wine
-rw-r--r-- 1 frog frog 3.7K Feb 17 16:52 .bashrc
-rw-r--r-- 1 frog frog 1.6K May 3 10:57 .bash_aliases
-rw-r--r-- 1 frog frog 807 Feb 17 16:52 .profile
-rw-r--r-- 1 frog frog 361 Feb 17 16:52 .pam_environment
-rw------- 1 frog frog 256 Feb 17 17:41 .pulse-cookie
-rw-r--r-- 1 frog frog 220 Feb 17 16:52 .bash_logout
-rw-rw-r-- 1 frog frog 199 Apr 14 22:12 .wget-hsts
-rw-r--r-- 1 frog frog 60 Apr 3 20:12 .gitconfig
lrwxrwxrwx 1 frog frog 29 May 5 21:36 .steampath -> /home/frog/.steam/sdk32/steam
lrwxrwxrwx 1 frog frog 27 May 5 21:36 .steampid -> /home/frog/.steam/steam.pid
-rw-r--r-- 1 frog frog 0 Feb 17 16:52 .sudo_as_admin_successful
-rw-r--r-- 1 frog frog 0 May 6 18:45 Test File
-rw-r--r-- 1 frog frog 0 May 6 18:48 Test File 1
-rw-r--r-- 1 frog frog 0 May 6 19:06 Test Really Long File That I Probably will Never See Anywhere But Might As Well Test It Cause Testing Stuff
Пример чистого вывода
Команда со странными интервалами:
printf "Permissions | Link Count | Owner | Group | Size | Date | Time | Name |\n Size " && ls --color=always --human-readable -S -l -a|awk '{print $1,"\t",$2,"\t",$3,"\t",$4,"\t",$5,"\t",$6,"\t",$7,"\t",$8,"\t",$9,s = ""; for (i = 10; i <= NF; i++) s = s $i " ";print s}'
Вывод:
frog@gamingrig-popos:~$ printf "Permissions | Link Count | Owner | Group | Size | Date | Time | Name |\n Size " && ls --color=always --human-readable -S -l -a|awk '{print $1,"\t",$2,"\t",$3,"\t",$4,"\t",$5,"\t",$6,"\t",$7,"\t",$8,"\t",$9,s = ""; for (i = 10; i <= NF; i++) s = s $i " ";print s}'
Permissions | Link Count | Owner | Group | Size | Date | Time | Name |
Size total 216K
-rw------- 1 frog frog 24K May 5 21:46 .bash_history
-rw------- 1 frog frog 6.6K Mar 29 20:28 .xsession-errors
drwxr-xr-x 37 frog frog 4.0K May 6 19:06 .
drwxr-xr-x 3 root root 4.0K Feb 17 16:52 ..
drwx------ 24 frog frog 4.0K May 6 20:03 .cache
drwx------ 44 frog frog 4.0K May 6 19:39 .config
drwxr-xr-x 2 frog frog 4.0K Feb 19 21:31 Desktop
drwxr-xr-x 4 frog frog 4.0K Mar 27 18:26 Documents
drwxr-xr-x 7 frog frog 4.0K May 4 12:45 Downloads
drwxr-xr-x 7 frog frog 4.0K Mar 22 17:33 .ftblauncher
drwx------ 2 frog frog 4.0K Feb 25 20:48 .GameGuide
drwx------ 2 frog frog 4.0K Feb 28 22:21 .gconf
drwx------ 3 frog frog 4.0K Feb 28 20:57 .gdfuse
drwx------ 3 frog frog 4.0K Feb 17 17:14 .gnome
drwx------ 3 frog frog 4.0K Feb 17 17:13 .gnupg
drwxr-xr-x 2 frog frog 4.0K Feb 28 20:57 GoogleDrive
drwxr-xr-x 3 frog frog 4.0K Mar 22 16:34 .java
drwxrwxr-x 5 frog frog 4.0K Mar 15 19:36 .local
drwxr-xr-x 13 frog frog 4.0K Mar 24 00:07 .minecraft
drwx------ 6 frog frog 4.0K Feb 24 19:32 .mozilla
drwxr-xr-x 2 frog frog 4.0K Feb 17 16:52 Music
drwx------ 4 frog frog 4.0K Feb 19 22:17 .nv
drwxr-xr-x 5 frog frog 4.0K Feb 17 20:50 .paradoxlauncher
drwxr-xr-x 2 frog frog 4.0K May 6 20:04 Pictures
drwx------ 3 frog frog 4.0K Feb 17 17:14 .pki
drwxr-xr-x 2 frog frog 4.0K Feb 17 16:52 Public
drwx------ 2 frog frog 4.0K Feb 25 20:48 .QtWebEngineProcess
drwxr-xr-x 5 frog frog 4.0K May 6 18:31 Scripts
drwx------ 2 frog frog 4.0K Apr 8 20:36 .ssh
drwxr-xr-x 3 frog frog 4.0K Feb 17 17:41 Steam
drwxr-xr-x 3 frog frog 4.0K May 6 14:39 .steam
drwxr-xr-x 2 frog frog 4.0K Feb 17 16:52 Templates
drwxr-xr-x 2 frog frog 4.0K May 6 18:45 Test
Dir
drwxr-xr-x 2 frog frog 4.0K May 6 18:48 Test
Dir 1
drwx------ 6 frog frog 4.0K Feb 17 17:47 .thunderbird
drwxr-xr-x 3 frog frog 4.0K Apr 29 18:43 .var
drwxr-xr-x 2 frog frog 4.0K Feb 17 16:52 Videos
drwxr-xr-x 2 frog frog 4.0K Apr 17 19:56 .vnc
drwxr-xr-x 4 frog frog 4.0K May 3 15:38 .wine
-rw-r--r-- 1 frog frog 3.7K Feb 17 16:52 .bashrc
-rw-r--r-- 1 frog frog 1.6K May 3 10:57 .bash_aliases
-rw-r--r-- 1 frog frog 807 Feb 17 16:52 .profile
-rw-r--r-- 1 frog frog 361 Feb 17 16:52 .pam_environment
-rw------- 1 frog frog 256 Feb 17 17:41 .pulse-cookie
-rw-r--r-- 1 frog frog 220 Feb 17 16:52 .bash_logout
-rw-rw-r-- 1 frog frog 199 Apr 14 22:12 .wget-hsts
-rw-r--r-- 1 frog frog 60 Apr 3 20:12 .gitconfig
lrwxrwxrwx 1 frog frog 29 May 5 21:36 .steampath
-> /home/frog/.steam/sdk32/steam
lrwxrwxrwx 1 frog frog 27 May 5 21:36 .steampid
-> /home/frog/.steam/steam.pid
-rw-r--r-- 1 frog frog 0 Feb 17 16:52 .sudo_as_admin_successful
-rw-r--r-- 1 frog frog 0 May 6 18:45 Test
File
-rw-r--r-- 1 frog frog 0 May 6 18:48 Test
File 1
-rw-r--r-- 1 frog frog 0 May 6 19:06 Test
Really Long File Name That I Probably will Never See Anywhere But Might As Well Test It Cause Testing Stuff
Пример вывода выдачи пробелов