stat -c illegal option


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting stat -c illegal option
# 1  
Old 04-15-2012
stat -c illegal option

I'm trying to get the size of each file, but when I try to use
Code:
stat -c %s <file>

I get the message
Code:
stat: illegal option -- c

Also, the man page for stat shows readlink,stat. It doesn't seem to match the man pages I've seen online.
what is going on here?
# 2  
Old 04-15-2012
This means that the same utility can be called with two different names and depending on with which name it was called, it behaves in a certain way. My guess is your online man page differs from your system's man page?
# 3  
Old 04-15-2012
What operating system, and version, are you using? Not all stat commands support the -c option. It is supported on my SUSE Linux box, but not on my FreeBSD box. Check the man page for the specific system you are dealing with.

---------- Post updated at 12:25 ---------- Previous update was at 12:24 ----------

Forgot to mention that under BSD the option is -f.
# 4  
Old 04-15-2012
Using OS X 10.6.8. I guess this version of stat is very different. I'll dig through the manual a bit more, but if anyone is familiar with how stat works on 10.6.8, maybe you can point me in the right direction!
# 5  
Old 04-15-2012
Try:
Code:
stat -f "%z" file

This User Gave Thanks to Scrutinizer For This Post:
# 6  
Old 04-15-2012
Thank you. I never would have figured that out. Mainly because I never would have thought to put the "%z" in quotes. Is this to keep the shell from expanding %?
# 7  
Old 04-15-2012
Ow, that was just habitual, the quotes are normally not required in this case...
Code:
stat -f %z file

Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Is "stat: illegal option -- -" an issue with hyphenated filename or flag problem?

Hi. I'm trying to install VMWare Workstation to run a virtual machine on my Mac OS, but running the bundle from bash(xterm) sh VMware-workstation-Full-11.0.0-2305329.x86_64.bundle (as suggested in install guide) comes up with error:stat: illegal option -- - usage: stat Digging... (5 Replies)
Discussion started by: defeated
5 Replies

2. Shell Programming and Scripting

Read: line 6: illegal option -e

For some reason read -e isn't working in my script. I need a directory as input from a user and I'd like for them to be able to use tab complete which is why I'm using -e. When the script is run, I get: read: line 6: illegal option -e In order to just figure out what is going on with the -e... (4 Replies)
Discussion started by: orangeSunshine
4 Replies

3. Shell Programming and Scripting

Help needed sed: illegal option -- i

hello. i have a script, but in solaris i get this message sed: illegal option -- i whats wrong? With Ubuntu there is no problem. Thanks for help. #!/bin/bash for file in $(find /directory..../Test/*.txt -type f) do head -n 1 $file | egrep '^#!' if then sed -i '2i\Headertext'... (3 Replies)
Discussion started by: fertchen
3 Replies

4. Solaris

date -d illegal option in Solaris

Hi All, Is it possible to run date -d option in Solaris? Do we have a work around so that -d option will be recognized by solaris as it is recognized by linux. I need this since i am using this in scripting and it works in Linux box. my problem is it doesn't work in solaris box. ... (6 Replies)
Discussion started by: linuxgeek
6 Replies

5. Solaris

Please help --setfacl: illegal option -- R

when i am executing setfacl -Rm u:ggoyal2:rwx,m:rwx dir i am getting error bash-3.00# setfacl -Rm u:ggoyal2:rwx,m:rwx dir setfacl: illegal option -- R usage: setfacl -f aclfile file ... setfacl -d acl_entries file ... setfacl -m acl_entries file ... setfacl -s acl_entries file... (2 Replies)
Discussion started by: manoj_dahiya22
2 Replies

6. UNIX for Dummies Questions & Answers

UNIX chauthtok(): illegal module option

Hi all, I just implemented PAM on my Solris 8/9 boxes and one of the entries I have got in the /etc/pam.conf is as followed, other password required pam_unix.so nullok remember=7 md5 shadow use_authtok However, once I set this and the following meesages appears in /var/adm/messages... (1 Reply)
Discussion started by: stancwong
1 Replies
Login or Register to Ask a Question