?
Solved

BASH (Linux) - View file permission

Posted on 2007-08-03
10
Medium Priority
?
2,127 Views
Last Modified: 2013-11-05
Making a simple script

I know how to change file permissions - but how do I view them (what command)?

Thanks
0
Comment
Question by:Ryan_R
  • 5
  • 5
10 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 19630138
ls -l filename

This will show the permissions
0
 
LVL 15

Author Comment

by:Ryan_R
ID: 19630145
Hi hongjun

I'm using that command already to view file statistics (I think).

Assuming I haven't got my wires crossed, does that command show both file statistics and permissions?
Thanks
0
 
LVL 15

Author Comment

by:Ryan_R
ID: 19630148
Just checked:

I did have the code for the permissions - it turns out that I needed to view File Statistics

Sorry to mislead you on that one
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 33

Expert Comment

by:hongjun
ID: 19630151
What type of stats do you want?
0
 
LVL 33

Expert Comment

by:hongjun
ID: 19630153
0
 
LVL 15

Author Comment

by:Ryan_R
ID: 19630174
I would imagine that the stats include items that you see when you r/click a file in Windows and choose Properties
Or if you show a folder in the 'Details' view

This would show you stuff like File Size, Date Modified, etc

However - I only want it to show these stats for the one file ($strFilename) - and not list the whole directory contents.  Is this possible?

Thanks (increasing points a bit)
0
 
LVL 15

Author Comment

by:Ryan_R
ID: 19630182
Perhaps the wc command will help - I'm unsure of it's extensions though
0
 
LVL 33

Accepted Solution

by:
hongjun earned 800 total points
ID: 19630198
try this

stat -c "%s %n" FILE

OR

ls -l FILE | { read a b c d size d1 d2 file; echo "$size $file"; }
0
 
LVL 33

Expert Comment

by:hongjun
ID: 19630201
File size

echo $(wc -c <FILENAME)
0
 
LVL 15

Author Comment

by:Ryan_R
ID: 19630205
Thanks hongjun

As it turns out, using    stat FILE    provides what I need.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Make the most of your online learning experience.
Simple Linear Regression
Progress

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question