stat command with ls -l


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting stat command with ls -l
# 8  
Old 08-13-2010
Quote:
Originally Posted by ygemici
a small correction
Code:
 
...........
while read -r a b c d e f g h i;
  do
    printf "%4s %3d %8s %8s %6d %s %s %s %s\n" "$(stat -c "%a" "${i% -> *}")" "$b" "$c" "$d" "$e" "$f" "$g" "$h" "$i";
 done

That would be dependent on how many columns ls -l produces (which depends on date/time formatting I think). On my system h corresponds to the file name...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Question on stat command

hello, I wanted to know which is the output of the stat command with a file, for example if I write on the terminal: stat ./unix.pdf i get the output: 754974726 6915670 -rwxrwxrwx 1 mbruno106 staff 0 90501 "Aug 13 13:26:02 2013" "Aug 13 13:26:02 2013" "Aug 13 13:26:02 2013" "Aug 13... (1 Reply)
Discussion started by: Marina2013
1 Replies

2. UNIX for Dummies Questions & Answers

Help with stat command

Hi Experts, I am here with very simple request: #!bin/bash a=`stat -c %y log1.csv` echo $a and this stat command returning value as 2013-08-11 05:42:10.000000000 -0400: But I want to see in mm/dd/yyyy format? any help is highly appreciated thank you ---------- Post... (9 Replies)
Discussion started by: parpaa
9 Replies

3. Shell Programming and Scripting

Stat value changes

Die to what all operations, the "Modify" and "Change" values of stat output changes for a file. I found, during editing a file, Change and Modify alters. When chmod'ing Change alters, while Modify doesnot alters. Is there more situations where these changes? (1 Reply)
Discussion started by: anil510
1 Replies

4. UNIX for Dummies Questions & Answers

Stat command

i know this command does not exist in solaris. however, i read somewhere on this forum that basically everything the stat command provides in other oses can be obtained in solaris using the ls command. i've searched the forum for a while now and i cant find the thread. does anyone know about... (1 Reply)
Discussion started by: SkySmart
1 Replies

5. Shell Programming and Scripting

AIX and HP-UX equivalent of Linux stat command

To list file permission/access right in octal format, linux has a command 'stat'. For example, we can use the followin - stat -c %a `find . -type f Is there any equivalent command in AIX and HP-UX to give the same result as linux 'stat' command? Please advice. (3 Replies)
Discussion started by: atanubanerji
3 Replies

6. Shell Programming and Scripting

Need file timestamp without stat command

Hi all, I want to check whether a file is not updated in last 15 minutes, for this i need to get timestamp of file, (yyyy:mm:dd:hh:mi:ss). I dont have access to STAT command :(. Please suggest a program or command to do this . Thanks, Saravana (1 Reply)
Discussion started by: sam_1210
1 Replies

7. Windows & DOS: Issues & Discussions

Does PowerSHell have *stat command analogs?

I.e. like vmstat, cpustat, iostat, fsstat, kstat ..etc? (1 Reply)
Discussion started by: Xcislav
1 Replies

8. Shell Programming and Scripting

hp-unix stat command to get last change date of file

I'm on hp-unix. I would like a variable to hold the last change date of a file. I looked at the man pages for stat, but I don't see any examples and can't get the syntax right. Can anyone help me? Thank you. (2 Replies)
Discussion started by: sboxtops
2 Replies

9. Shell Programming and Scripting

Equivalent command to 'stat'

Can anyone tell me which is the equivalent command to 'stats' in ksh shell which discribes the file system? Thanks in advance Regards, Im_new (6 Replies)
Discussion started by: im_new
6 Replies

10. Shell Programming and Scripting

stat command

how can ý use "stat command"????.. (2 Replies)
Discussion started by: emreatlier
2 Replies
Login or Register to Ask a Question
umask(1)						      General Commands Manual							  umask(1)

NAME
umask - Displays or sets the file mode creation mask SYNOPSIS
umask [-S] [mask] Note The C shell has a built-in version of the umask command. If you are using the C shell, and want to guarantee that you are using the com- mand described here, you must specify the full path /usr/bin/umask. See the csh(1) reference page for a description of the built-in com- mand. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: umask: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Produce symbolic output. Output is produced in a format that is recognized on a subsequent invocation of umask as a mask operand to restore the previous file mode creation mask. If the -S option is not used, output is displayed as an octal integer, but is still usable as input on a subsequent invocation of the umask command. OPERANDS
A string specifying the new file mode creation mask. This string may may be an octal value or a symbolic_mode value. For a symbolic_mode value, the new value of the file mode creation mask is the logical complement of the file permission bits por- tion of the file mode specified by the symbolic_mode string. In a symbolic_mode value, the characters + and - are interpreted relative to the current file mode creation mask; + causes the bits for the indicated permissions to be cleared in the mask; - causes the bits for the indicated permissions to be set in the mask. The file mode creation mask is set to the resulting numeric value. In the obsolescent octal integer form of mode, the specified bits are set in the file mode creation mask. DESCRIPTION
The umask command sets the file mode creation mask of the current shell execution environment to the value specified by the mask oper- and. This mask affects the initial value of the file permission bits of subsequently created files. If the mask operand is not specified, the umask command writes the value of the invoking process's file mode creation mask to standard out- put. If the -S option is specified, the output is in the following format: "u=%s,g=%s,o=%s ", <owner permissions>, <group permissions>, <other permissions>" The three values are combinations of letters from the set {r, w, x}; the presence of a letter indicates that the corresponding bit is clear in the file mode creation mask. NOTES
Any mask operand such as -r, -w, -x, or anything beginning with a hyphen, must be preceded by -- to keep it from being interpreted as a option. Since umask affects the current shell execution environment, it is provided as a shell regular built-in. In contrast to the nega- tive permission logic provided by the file mode creation mask and the octal number form of the mask argument, the symbolic form of the mask operand specifies those permissions that are left alone. Although the references to octal modes are obsolescent in the ISO/IEC 9945-2:1993 standard, they are maintained for portable applications until further notice. RESTRICTIONS
If umask is called in a subshell or separate utility execution environment, it does not affect the file mode creation mask of the caller's environment. A separate execution environment could be one of the following: (umask 002) nohup umask ... find . -exec umask ... ; EXIT STATUS
The following exit values are returned: The file mode creation mask was successfully changed, or no mask operand was supplied. An error occurred. EXAMPLES
To set the file mode creation mask so that subsequently created files have their write by all others bit cleared, enter either of the fol- lowing commands: umask a=rx,ug+w umask 002 If the file mode creation mask was set with either of the above commands, the umask command can be used to write out the current value of the mask. To write the value in octal format, enter: umask This provides the output: 0002 To write the value in symbolic format, enter: umask -S This provides the output: u=rwx,g=rwx,o=rx The following sequence of commands is an example of how to save the current file mode creation mask and later restore the value using the umask command and octal integer formats. Examine the current value of the mask: umask The current mask is reported as: 022 Save the current value, and verify the saved value: SAVEMASK =`umask` echo $SAVEMASK The saved value is reported as: 022 Change the current mask: umask 444 Verify the change: umask The new mask is reported: 0444 Restore the previous mask: umask $SAVEMASK Verify the restored value: umask The value is now restored: 022 The following sequence of commands is an example of how to save the current file mode creation mask and later restore the value using the umask command and symbolic_mode formats. Examine the current value of the mask: umask -S The current mask is reported as: u=rwx,g=rx,o=rx Save the current value, and verify the saved value: SAVEMASK=`umask -S` echo $SAVE- MASK The saved value is reported as: u=rwx,g=rx,o=rx Change the current mask: umask a= Verify the change: umask -S The new mask is reported: u=,g=,o= Restore the previous mask: umask $SAVEMASK Verify the restored value: umask -S The value is now restored: u=rwx,g=rx,o=rx To set the file mode creation mask so that subsequently created files have all their write bits cleared, enter: umask -- -w ENVIRONMENT VARIABLES
The following environment variables affect the execution of umask: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: chmod(1) Functions: chmod(2), umask(2) Standards: standards(5) umask(1)