Hot answers tagged

13

This will make nl start from 0 : $ ls -lh | nl -v 0 0 total 24 1 -rw-rw-r-- 1 wolf wolf 186 Sep 24 22:18 01.py 2 -rw-rw-r-- 1 wolf wolf 585 Sep 24 22:21 02.py 3 -rw-rw-r-- 1 wolf wolf 933 Sep 24 22:26 03.py


11

The question marks mean that ls can’t read the corresponding information; it reports that at the top of its output: ls: cannot access 'gvfs': Permission denied gvfs is inaccessible to all users except its owner, even to root, because it’s a user-owned FUSE mount — such mounts are inaccessible even to root, to prevent a malicious FUSE process from taking ...


11

Consume the first line with something else and pass the rest to nl $ ls -lh | { sed -u q; nl; } total 24 1 -rw-rw-r-- 1 wolf wolf 186 Sep 24 22:18 01.py 2 -rw-rw-r-- 1 wolf wolf 585 Sep 24 22:21 02.py 3 -rw-rw-r-- 1 wolf wolf 933 Sep 24 22:26 03.py sed (with -u to disable buffering), will consume one line and quit, implicitly ...


7

It's kind of ugly, but at least with the GNU Coreutils implementation of nl you can specify the lines to be numbered via a regular expression - since t is not one of the possible file types in the ls long-list output1 you could do ls -lh | nl -bp'^[^t]' Unfortunately this does not preserve the output alignment though. Perhaps the most formally correct ...


5

You could try it with awk instead: ls -lh | awk '{printf("%5s ",NR==1?" ":NR-1); print}' This will print the "totals" line without numbering it, and all remaining lines with numbers, right-adjusted, with a field width of 5. The space between number and line content will be two spaces (the text after the 5s in the printf() ...


2

Directories do have hard links, but they’re not arbitrary. Each directory contains a hard link to its parent directory, ..; your /etc contains 142 sub-directories. The other two are /etc itself and /etc/.. To find symlinks, you need to tell find to follow them: find -L / -xdev -samefile /etc Instead of excluding paths you’re not interested in, it’s more ...


2

Because they're on different file systems. It's the device_id:inode tuple which uniquely identifies a file, not just the inode. # mount ... /dev/sda8 on / type ext4 (rw,relatime,errors=remount-ro) tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=816612k,mode=755) udev on /dev type devtmpfs (rw,nosuid,relatime,size=4032552k,nr_inodes=1008138,mode=755)


1

Catalina has separate controls to limit access to Desktop, Documents and Downloads. go to System Preferences open "Security & Privacy" click on the "Privacy" tab in the list on the left select "Files and Folders" in list on the right look for "Terminal" (or iTerm if that is what you are using) enable the checkbox ...


1

If we split this by parts: find . -name "*.txt" -exec ls -l {} \; find . = Find all files/directories starting from the current directory -name "*.txt" = Filter only files/directories with names ending in *.txt -exec = Execute the following command for each file ls -l {} = Run ls -l ({} gets substituted with the name of the file) \; = ...


Only top voted, non community-wiki answers of a minimum length are eligible