• We had to restore from a backup today after a failed software update. Backup was from 0000 EDT and restored it at 0800 EDT so we lost about 8hrs. Today is 07/20/2024. More info here.

Bash Script - ls-octal.sh - ls + octal permissions

SlowCoder

Gold Member
Gold Supporter
Joined
May 2, 2022
Messages
455
Reaction score
317
Credits
3,611
This is my solution from this thread. Member wanted to list all files in a directory with their octal permissions.
This script performs a ls -l style file list, with the octal permissions in the first column. The output formatting isn't perfect, but gets the point across.

Script:
Bash:
#!/bin/bash

# list all files in current directory, and include their octal permissions

# include hidden
shopt -s dotglob

# iterate
for f in *
do
    echo -n $(stat "$f" -c '%a')" "
    echo "$(ls -ld --color=always "$f")"
done
 


If it's ok, I prefer to create a separate thread for my scripts, which will allow conversations to take place without getting lost in the shuffle. I created a post in the new thread, and linked them to get us started.
 
All good. My goal is a thread without much digression, so maybe that'll keep any digression to the threads you made. That'll help!
 
Did you mean to post that in this thread:
How about this: I'll put smaller scripts into the main thread, which will help get the thread started. But my larger scripts I'd like to make their own to make conversation easier. Good?
 
Either way works. The main goal is a central place where people can find 'em. So, that works. The secondary goal is to keep it on topic. That remains to be seen!
 


Top