getwd(3C) Standard C Library Functions getwd(3C)NAME
getwd - get current working directory pathname
SYNOPSIS
#include <unistd.h>
char *getwd(char *path_name);
DESCRIPTION
The getwd() function determines an absolute pathname of the current working directory of the calling process, and copies that pathname into
the array pointed to by the path_name argument.
If the length of the pathname of the current working directory is greater than (PATH_MAX + 1) including the null byte, getwd() fails and
returns a null pointer.
RETURN VALUES
Upon successful completion, a pointer to the string containing the absolute pathname of the current working directory is returned. Other-
wise, getwd() returns a null pointer and the contents of the array pointed to by path_name are undefined.
ERRORS
No errors are defined.
USAGE
For portability to implementations conforming to versions of the X/Open Portability Guide prior to SUS, getcwd(3C) is preferred over this
function.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
|ATTRIBUTE TYPE |ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO getcwd(3C), attributes(5), standards(5)SunOS 5.11 24 Jul 2002 getwd(3C)
Check Out this Related Man Page
getwd(3C)getwd(3C)NAME
getwd() - get pathname of current working directory
SYNOPSIS DESCRIPTION
places the absolute pathname of the current working directory in the array pointed to by buf, and returns buf.
If the length of the pathname of the current working directory is greater than bytes, fails and returns a null pointer.
RETURN VALUE
Upon successful completion, returns a pointer to the current directory pathname. Otherwise, it returns NULL with set.
ERRORS
fails if the following condition is encountered:
The length of the specified path name exceeds
bytes, or the length of a component of the path name exceeds bytes while is in effect.
may fail if any of the following conditions are encountered:
Read or search permission is denied for a component of pathname.
buf points outside the allocated address space of the process. may not always detect this error.
EXAMPLES
#include <stdio.h>
#include <unistd.h>
char *cwd;
char buf[PATH_MAX+1];
...
if ((cwd = getwd(buf)) == NULL) {
perror("getwd");
exit(1);
}
puts(cwd);
WARNINGS
For portability, is preferred over this function.
AUTHOR
was developed by HP and the University of California, Berkeley.
SEE ALSO getcwd(3C), thread_safety(5).
STANDARDS CONFORMANCE getwd(3C)
Hi ,
When try to search for files at home directory its working fine ,
but its not working when try for another directory
Working
pmo@xx:/xx #find . / -name *14104* -type f -print 2>/dev/null
/xx/devt/jobs/JOB_14104_EXTRACT.bat
/xx/devt/jobs/JOB_14104_LOAD.bat... (1 Reply)
Hi All,
I have been using the below syntax in unix and it has been working fine, Later when we migrated to Linux by having folder wise pemission its not working fine. So can you let us know where the list file could be created ?
awk '/^XXX/{key=$0;print > "list";next} /^YYY/ {print... (4 Replies)
Hello everyone,
I need some help renaming files. I have a directory with a bunch of subfolders in it like so with DWI being the working directory and the 3 levels after it being subdirectories
home/user/Documents/DWI/111180-100/3t_2016-01-07_21-42/003_DTI_siemens_TClessdistort/dtifit_FA.nii.gz... (8 Replies)