The ls output is showing the size of the files listed (note that a directory is just one type of a file).
The du -hs output is showing the sizes of the blocks allocated to the file and (when the file is a directory) the size of the blocks allocated to the directory added to the sizes of the blocks allocated to all files in the file hierarchy rooted in that directory. Note also that the sizes of files in a file hierarchy reported by du -hs might not be what you expect. If there are hard links to files in a hierarchy, the blocks allocated to each linked file will only be counted once. Therefore, the sum of the sizes reported by:
Code:
du -hs dir1 dir2
might not be the sum of the sizes reported by:
Code:
du -hs dir1;du -hs dir2
And, if there are sparse files, the file size may be huge, but the number of blocks allocated to the file may be tiny.
And note that the size of a directory varies from filesystem type to filesystem type. On some filesystem types, the size of a directory shown by ls will be the size of the directory entries in that directory; in other filesystem types, it will just be the number of directory entries contained in that directory; and in other filesystem types, it might be something else. (On some filesystem types, some directory entries can be stored in the i-node for the directory. This makes the size of the directory zero until enough space is needed by directory entries to overflow the space in the i-node.)
This User Gave Thanks to Don Cragun For This Post:
I am trying to load a group of files and their last dates modified into a text file that will in turn be used with SQL*Loader to load these files into Oracle. I am using a *.ksh script. I am getting the name of the file in by using the following:
for file_ext in 'cat loaddir.ext';
do
find... (2 Replies)
Hello,
I'm on a practical training and i have to change a shell script which print out a HTML-File with all Printers (and features example: IP, Mac etc.) they have in the factory.
The Features of the Printers are on each separate file. i mean every printer have an own file with it features.
... (12 Replies)
i have a k shell script that grep less than certain modified date
-------------------------------------------------
#!/bin/ksh
for i in *
do
day=`ls -ltr | grep $i | tr -s " " | cut -d " " -f6-7 | awk 'substr($0,7,4)substr($0,1,5)substr($0,11)<"Feb 1"' `
echo $day
done... (2 Replies)
Sorry for the basic question, but I have a feeling that my developers are circumventing our change control process, and I want to be able to easily keep track of the last modified date of sub-folders of the production folder.
Basically, we have this major folder PROD, and then each application... (1 Reply)
Hello all - I've looked and have not been able to find a "find" command that will list the last modified date of files within a specific directory and its subdirectories. If anyone knows of such a command it would be very much appreciated!
If possible, I would like to sort this output and have... (5 Replies)
Hi ,
In my directory , i have many days file but i want to see all those which are of todays date.
i tried this but it gives all the files
mtime -0 |ls -ltr
I tried the below option as well.
19635 find -iname "*.LOG" -mtime
19636 ls -ltr *.LOG -mtime -1
19637 ls -ltr *.LOG... (7 Replies)
Can someone draw up a script that for every file, folder and subfolder and files that will copy the creation date over top of the modified date??
I know how to touch every file recursively, but no idea how to read a files creation date then use that to touch the modification date of that file,... (3 Replies)
I'm using a script that I need to get a file's "last modified date" in a format like 01:51:14 PM. We are running on AIX 6.1.0.0. I can't seem to find the right command parameters. Help! (4 Replies)
Hi,
Am performing a find based on filename and result can contain multiple files being found
Let's say my find command is
find /Archive -f -name 12345.pdf
and result of find command is
/Archive/Folder A/12345.pdf
/Archive/Folder B/12345.pdf
please note white space in folder names
I... (2 Replies)
Discussion started by: gigagigosu
2 Replies
LEARN ABOUT SUNOS
newtask
newtask(1) User Commands newtask(1)NAME
newtask - create new task and optionally change project
SYNOPSIS
newtask [-p project] [-v] [-c pid | [-Fl] [command...]]
DESCRIPTION
The newtask command executes the user's default shell or a specified command, placing the executed command in a new task owned by the spec-
ified project. The user's default shell is the one specified in the passwd database, and is determined using getpwnam().
Alternatively, newtask can be used to cause an already running process to enter a newly created task. A project for the new task can also
be specified in this form of the command. This might be desirable for processes that are mission critical and cannot be restarted in order
to put them into a new project.
In the case that extended accounting is active, the newtask command can additionally cause the creation of a task accounting record marking
the completion of the preceding system task.
OPTIONS
The following options are supported:
-c pid Cause a running process to enter a newly created task. A project for the new task can also be specified using the -p option. The
invoking user must either own the process or have super-user privileges.
If the project is being changed, the process owner must be a member of the specified project, or the invoking user must have
super-user privileges. When the project is changed for a running process, its pool binding as well as resource controls are modi-
fied to match the configuration of the new project. Controls not explicitly specified in the project entry is preserved.
This option is incompatible with the -F and -l options.
-F Creates a finalized task, within which further newtask or settaskid(2) invocations would fail. Finalized tasks can be useful at
some sites for simplifying the attribution of resource consumption.
-l Changes the environment to what would be expected if the user actually logged in again as a member of the new project.
-p Changes the project ID of the new task to that associated with the given project name. The invoking user must be a valid member of
the requested project, or must have super-user privileges, for the command to succeed. If no project name is specified, the new
task is started in the invoking user's current project.
-v Verbose: displays the system task id as the new system task is begun.
OPERANDS
The following operands are supported:
project The project to which resource usage by the created task should be charged. The requested project must be defined in the
project databases defined in nsswitch.conf(4).
command The command to be executed as the new task. If no command is given, the user's login shell is invoked. (If the login shell
is not available, /bin/sh is invoked.)
EXAMPLES
Example 1: Creating a New Shell
The following example creates a new shell in the canada project, displaying the task id:
example$ id -p
uid=565(gh) gid=10(staff) projid=10(default)
example$ newtask -v -p canada
38
example$ id -p
uid=565(gh) gid=10(staff) projid=82(canada)
Example 2: Running the date Command
The following example runs the date command in the russia project:
example$ newtask -p russia date
Tue Aug 31 11:12:10 PDT 1999
Example 3: Changing the Project of an Existing Process
The following example changes the project of the existing process with a pid of 9999 to russia:
example$ newtask -c 9999 -p russia
EXIT STATUS
The following exit values are returned:
0 Successful execution.
1 A fatal error occurred during execution.
2 Invalid command line options were specified.
FILES
/etc/project Local database containing valid project definitions for this machine.
/proc/pid/* Process information and control files.
ATTRIBUTES
See attributes(5) for a description of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO proc(1), id(1M), poolbind(1M), execvp(2), setrctl(2), settaskid(2), setproject(3PROJECT), nsswitch.conf(4), proc(4), project(4),
attributes(5)SunOS 5.10 17 Nov 2004 newtask(1)