First, the column printed by ls that looks like -rwxr-xr-x indicates the file's permissions and the file type. The type is indicated by the first character: d is directory, - is regular file, l is symbolic link, etc. The POSIX man page lists all of the possible types.
The remainder is three sets of permission flags for owner, group and other. For each set contains the read, write and execute permission (e.g. rwx, r-x, rw- etc.). Again the man page explains all.
The find command you listed does indeed target only regular files. That is what the -type f option does. If you use -type d then it will list directories only. However, it seems that you want a further limitation and only want to list a directory that has no subdirectories. I don't believe that find has that ability.
To list only the directories with no subdirectories, and then list the files in each of those directories, piping the output of find to awk (or similar script) to further limit the list, and then using the ls command to list the directoies is required. Something like this will find all directories in the current directory that do not have subdirectories, and lists their contents:
I am in a fix.......
I have to write a backup script to backup say Folder A.
Folder A contains n folders 1,2 ,3 .....n.
my script should copy A without folder 2 & 3.
Is there anyway I can do it without writing individual copy commands????
Please help.... (1 Reply)
I am in a fix.......
I have to write a backup script to backup say Folder A.
Folder A contains n folders 1,2 ,3 .....n.
my script should copy A without folder 2 & 3.
Is there anyway I can do it without writing individual copy commands????
Please help.... (5 Replies)
Hi all,
Is it possible to find a file on a server without knowing the file path? And when the file is found is it possible to find out the file path?
I would like to find a file by typing: find server/ -name "filename"
Instead of: find server/folder1/folder2/folder3/ -name "filename"
Can... (5 Replies)
I want to create a script which will delete all folders which are over 5 hours old in HP-UX 11.11.
I tried to use the "find" command but it didn't have an option for searching files/folder by hours.
Could some one tell me how to achieve this in HP-UX with only using the standard OS commands and... (4 Replies)
I am trying to make a unix shell script that will make 99 folders 99 deep (counting the first level folders). So far i have made it make the first 99 folders and 99 more in all of the folders. The only problem is the only way i have found is copying and pasting part of the script over and over and... (18 Replies)
I have a folder like this
ls input1
dir1 dir2 dir3 file1 file2 file3
dir1, dir2 and dir3 are sub-folders inside the folder input1
ls input2
dir1 dir2 dir3 file1 file2 file3
My dir1 in input1 folder has files f1, f2, f3 and f4.
My dir1 in input2 folder has file f4 and f5.
... (3 Replies)
Hi
Can i archive folder and folders in with the tar command
My files are located in subfolders
Eg: Folder1/Folder1_1/*.pdf
Folder1/Folder1_2/*.pdf
Folder1/Folder1_3/*.pdf
so i would like to tar all the files in Folder1_1 and Folder1_2 only not Folder1_3 that should be done next... (2 Replies)
I am trying to cat 3 files. They all have the same name MFExtract.txt. But, they are in 3 seperate file names. Any idea how I could cat the 3 together. It's throwing me off figuring out a way because the names are the same. I was thinking just doing a 3 cat commands with the full path names and... (2 Replies)
Hi,
So i know we use cp -r as a basic to copy folders/files.
I would like this BUT i would like to show the output of the files being copied.
With the amazing knowledge i have i have gone as far as this:
1) find source/* -exec cp -r {} target/ \;
2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies
LEARN ABOUT V7
ls
LS(1) General Commands Manual LS(1)NAME
ls - list contents of directory
SYNOPSIS
ls [ -ltasdrucifg ] name ...
DESCRIPTION
For each directory argument, ls lists the contents of the directory; for each file argument, ls repeats its name and any other information
requested. The output is sorted alphabetically by default. When no argument is given, the current directory is listed. When several
arguments are given, the arguments are first sorted appropriately, but file arguments appear before directories and their contents. There
are several options:
-l List in long format, giving mode, number of links, owner, size in bytes, and time of last modification for each file. (See below.)
If the file is a special file the size field will instead contain the major and minor device numbers.
-t Sort by time modified (latest first) instead of by name, as is normal.
-a List all entries; usually `.' and `..' are suppressed.
-s Give size in blocks, including indirect blocks, for each entry.
-d If argument is a directory, list only its name, not its contents (mostly used with -l to get status on directory).
-r Reverse the order of sort to get reverse alphabetic or oldest first as appropriate.
-u Use time of last access instead of last modification for sorting (-t) or printing (-l).
-c Use time of last modification to inode (mode, etc.) instead of last modification to file for sorting (-t) or printing (-l).
-i Print i-number in first column of the report for each file listed.
-f Force each argument to be interpreted as a directory and list the name found in each slot. This option turns off -l, -t, -s, and
-r, and turns on -a; the order is the order in which entries appear in the directory.
-g Give group ID instead of owner ID in long listing.
The mode printed under the -l option contains 11 characters which are interpreted as follows: the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.
The next 9 characters are interpreted as three sets of three bits each. The first set refers to owner permissions; the next to permissions
to others in the same user-group; and the last to all others. Within each set the three characters indicate permission respectively to
read, to write, or to execute the file as a program. For a directory, `execute' permission is interpreted to mean permission to search the
directory for a specified file. The permissions are indicated as follows:
r if the file is readable;
w if the file is writable;
x if the file is executable;
- if the indicated permission is not granted.
The group-execute permission character is given as s if the file has set-group-ID mode; likewise the user-execute permission character is
given as s if the file has set-user-ID mode.
The last character of the mode (normally `x' or `-') is t if the 1000 bit of the mode is on. See chmod(1) for the meaning of this mode.
When the sizes of the files in a directory are listed, a total count of blocks, including indirect blocks is printed.
FILES
/etc/passwd to get user ID's for `ls -l'.
/etc/group to get group ID's for `ls -g'.
LS(1)