Generate the File Attributes in the system


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Generate the File Attributes in the system
# 1  
Old 06-12-2009
Generate the File Attributes in the system

Hello Folks,

I want to generate the file attributes of the system and needs to write into the text file.

I am running the command "ls -Rl" to get the details of the files from the current directory.

I am getting the output.

Code:
./linux-2.6.29.4/arch:
total 10
drwxr-xr-x  9 1138 5000  328 May 18 16:52 alpha
drwxr-xr-x 68 1138 5000 2104 May 18 16:52 arm
drwxr-xr-x 11 1138 5000  352 May 18 16:52 avr32
drwxr-xr-x 17 1138 5000  552 May 18 16:52 blackfin
drwxr-xr-x  8 1138 5000  272 May 18 16:52 cris
drwxr-xr-x  7 1138 5000  288 May 18 16:52 frv
drwxr-xr-x  8 1138 5000  392 May 18 16:52 h8300
drwxr-xr-x 17 1138 5000  552 May 18 16:52 ia64
-rw-r--r--  1 1138 5000 3022 May 18 16:52 Kconfig
drwxr-xr-x  9 1138 5000  304 May 18 16:52 m32r
drwxr-xr-x 22 1138 5000  608 May 18 16:52 m68k
drwxr-xr-x  7 1138 5000  280 May 18 16:52 m68knommu
drwxr-xr-x 35 1138 5000  944 May 18 16:52 mips
drwxr-xr-x 11 1138 5000  368 May 18 16:52 mn10300
drwxr-xr-x 10 1138 5000  408 May 18 16:52 parisc
drwxr-xr-x 14 1138 5000  424 May 18 16:52 powerpc
drwxr-xr-x 13 1138 5000  424 May 18 16:52 s390
drwxr-xr-x 15 1138 5000  472 May 18 16:52 sh
drwxr-xr-x 11 1138 5000  344 May 18 16:52 sparc
drwxr-xr-x 11 1138 5000  752 May 18 16:52 um
drwxr-xr-x 23 1138 5000  728 May 18 16:52 x86
drwxr-xr-x 10 1138 5000  328 May 18 16:52 xtensa

./linux-2.6.29.4/arch/alpha:
total 52
drwxr-xr-x 3 1138 5000   248 May 18 16:52 boot
-rw-r--r-- 1 1138 5000 20414 May 18 16:52 defconfig
drwxr-xr-x 3 1138 5000    72 May 18 16:52 include
-rw-r--r-- 1 1138 5000 19491 May 18 16:52 Kconfig
-rw-r--r-- 1 1138 5000  1355 May 18 16:52 Kconfig.debug
drwxr-xr-x 2 1138 5000  2384 May 18 16:52 kernel
drwxr-xr-x 2 1138 5000  1688 May 18 16:52 lib
-rw-r--r-- 1 1138 5000  2258 May 18 16:52 Makefile
drwxr-xr-x 2 1138 5000   152 May 18 16:52 math-emu
drwxr-xr-x 2 1138 5000   176 May 18 16:52 mm
drwxr-xr-x 2 1138 5000   256 May 18 16:52 oprofile

I want the output through the script that converts the output in the below mentioned format

I want the output in such a way, each file shows the full path from the "/" directory.

Code:
total 10
drwxr-xr-x  9 1138 5000  328 May 18 16:52 /usr/src/kernels/linux-2.6.29.4/archalpha
drwxr-xr-x 68 1138 5000 2104 May 18 16:52 /usr/src/kernels/linux-2.6.29.4/archarm
drwxr-xr-x 11 1138 5000  352 May 18 16:52 /usr/src/kernels/linux-2.6.29.4/archavr32

I have tried many sed regex but I did not make it work.

Could you please help me out to write this script?

Thanks,
Saurabh
# 2  
Old 06-12-2009
find command will give almost similar kind of o/p except two extra fields in the begining
you can get rid of that using awk or something else
Code:
find . -ls -long

# 3  
Old 06-12-2009
Thanks for the help. The solution was really meant to me.

However, I have only one issue. In this list, I want the details of the device file that contains the major num and minor number. If I could get this details, it would be great.

Is there any command with this command to get that details?

Thanks,
Saurabh
# 4  
Old 06-12-2009
read the find man page
Quote:
-ls
Always evaluates to the value True. Causes the current path name to be printed together with its associated statistics. These statistics include
the following:
* I-node number
* Size in kilobytes (1024 bytes)
* Protection mode
* Number of hard links
* User
* Group
* Size in bytes
* Modification time
If the file is a special file, the size field contains the major and minor device numbers. If the file is a symbolic link, the path name of the
linked-to file is printed preceded by the -> (hyphen, greater than) symbols. Formatting is similar to that of the ls -filds command, however
formatting is done internally without executing the ls command, therefore differences in output with the ls command may exist, such as with the
protection mode.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

File attributes ????

I'm trying to sort out the charing of a problem folder, in the 'ls -l' list is shows as: d???????????? ? ? ? ? ? Pi-Share PiShare is the name of the directory, all the ??s make no sense to me at all, and no user (there are only two, pi and root) can make any changes to it.... (4 Replies)
Discussion started by: MuntyScrunt
4 Replies

2. UNIX for Dummies Questions & Answers

How to remove attributes of a file?

Hello, I opened a file by accident (with a java program, which has been uninstalled!) and from then on, all the file with .fasta extension has been changed with an icon (So annoying!!) and the file attributes has been changed with the property: Type: application/x-wine-extension-fasta type... (6 Replies)
Discussion started by: yifangt
6 Replies

3. Shell Programming and Scripting

How do I create a shell script that would generate a system notification.

I am a student, and I have project to complete. The project is to create a power point presentation with the following guidelines: You are the system admin for a medium sized Internet company that has its primary production web server running on UNIX/Linux. Your technical IT director would like... (1 Reply)
Discussion started by: jcottrell
1 Replies

4. UNIX Desktop Questions & Answers

file attributes and exception

hi, I want to know the date the file was created or modified. I can do this using ls, ll -ltr etc... I want to do this in a function (so If the file date is older then a week I can report it), is there a way? another thing... In sql function, I can catch exceptions, is there a way to do this... (1 Reply)
Discussion started by: krem
1 Replies

5. Shell Programming and Scripting

Assigning file attributes to variables

Hi, I'm trying to assign the permissions, owner and group of a file to seperate variables, but using ls -l filename | awk '{print $1 "\t" $3 "\t" $4}' gives the owner as tom.ja instead of tom.james Is there any way to expand it so i get the full name, or is there an easier way to get them... (5 Replies)
Discussion started by: olimiles
5 Replies

6. Shell Programming and Scripting

file attributes

How to retrieve file attributes in a sh/bash script (modification time, access time, size, etc.)? (1 Reply)
Discussion started by: Hitori
1 Replies

7. UNIX for Dummies Questions & Answers

how to find system attributes

hi, i am very- very new to unix i have os - sun solaris 5.9 and i want to learn more about system attributes for example, the make - model of machine , operating system & patch versions can somebody tell me a usefull command to learn these? any help would be apreciated, regards to all,... (3 Replies)
Discussion started by: merope
3 Replies

8. Shell Programming and Scripting

file attributes

how do we set file attributes at shell prompt (2 Replies)
Discussion started by: hytechpro
2 Replies

9. Shell Programming and Scripting

rcp and file attributes

Good day Does anyone have an idea on how I can rcp a file together with its attributes. owner,group, permissions ? Regards J (2 Replies)
Discussion started by: jhansrod
2 Replies

10. UNIX for Advanced & Expert Users

Need to view all the attributes for a file/node

I need to find out when a file has been created. 'ls -l' just lists the last date the file was modified, not the creation date. I have also noticed when viewing the attributes through NT, the last modified date is the same as the file creation date. I thought maybe this was a fault due to Samba. ... (2 Replies)
Discussion started by: dpalmer
2 Replies
Login or Register to Ask a Question