I need to move a bunch of files into folders that have the same name. I wanted to either do this with some filter command or some type of batch file that I could save that would already include all of the mv commands since I will have to do this process often. Whatever method you think is easier.
... (7 Replies)
Hi, i have number of files in a directory to be processed. the problem is some of the files does not have a header and the process is giving an error of no header found.
example of good file :
file1
HDR|20080803233401
record 1
record 2
TRA|2
example of a bad file in the same dir
... (6 Replies)
Hi,
I have hundered's of files of the name
CMP_PORT_IN_P200903271623042437_20090328122430_err.xml in error directory of todays date ie 20090328 and in the file name 5th field specifies date only now i want to move all files of 20090328 to another directory i.e reprocess directory.
So... (3 Replies)
I want to move the files in a dir to different dirs based on their file names.
Ex: i have 4 different files with name -
CTS_NONE_10476031_MRL_PFT20081215a.txt
CTS_NONE_10633009_MRL_PFT20091020a.txt
CTS_NONE_10345673_MRL_PFT20081215a.txt
CTS_NONE_10872456_MRL_PFT20091020a.txt
and the 1st... (2 Replies)
Hi All
I need a script to manipulate files based on a filename:
example filename: 66600_042706.pdf
the script will create a directory 66000 only if this directory is not existing. If that directory is existing it will just move the file to 66000/666000_042706.pdf
in addition, i want to... (4 Replies)
I know this gets covered quite a bit in the forum and I think there is enough there for me to figure out how to do what I am trying to do, I just don't think I would do it very efficiently so I am going to ask the question...
I have database log files with date and time stamps in the file like
... (7 Replies)
Need a script to move the files from one dir to other dir and at the same time it has to read the log in the source dir. Please help me ASAP. (4 Replies)
Move all files starting with a specific name to different directory.
This shell script program should have three parameters
File Name
Source Directory
Destination Directory
User should be able to enter ‘AB_CD*' in file name parameter. In this case all the files starting with AB_CD will... (1 Reply)
Hello all,
I'm very new to shell scripting and need quite urgently to do this thing for my student job. I have a directory called "vectors" with a bunch of files all named ".vector". also i have for each of those files a directory with the name . I now want to move each of those *.vector files... (2 Replies)
Discussion started by: sherresh
2 Replies
LEARN ABOUT REDHAT
dirname
DIRNAME(3) Linux Programmer's Manual DIRNAME(3)NAME
dirname, basename - Parse pathname components
SYNOPSIS
#include <libgen.h>
char *dirname(char *path);
char *basename(char *path);
DESCRIPTION
The functions dirname and basename break a null-terminated pathname string into directory and filename components. In the usual case,
dirname returns the string up to, but not including, the final '/', and basename returns the component following the final '/'. Trailing
'/' characters are not counted as part of the pathname.
If path does not contain a slash, dirname returns the string "." while basename returns a copy of path. If path is the string "/", then
both dirname and basename return the string "/". If path is a NULL pointer or points to an empty string, then both dirname and basename
return the string ".".
Concatenating the string returned by dirname, a "/", and the string returned by basename yields a complete pathname.
Both dirname and basename may modify the contents of path, so if you need to preserve the pathname string, copies should be passed to these
functions. Furthermore, dirname and basename may return pointers to statically allocated memory which may be overwritten by subsequent
calls.
The following list of examples (taken from SUSv2) shows the strings returned by dirname and basename for different paths:
path dirname basename
"/usr/lib" "/usr" "lib"
"/usr/" "/" "usr"
"usr" "." "usr"
"/" "/" "/"
"." "." "."
".." "." ".."
EXAMPLE
char *dirc, *basec, *bname, *dname;
char *path = "/etc/passwd";
dirc = strdup(path);
basec = strdup(path);
dname = dirname(dirc);
bname = basename(basec);
printf("dirname=%s, basename=%s
", dname, bname);
free(dirc);
free(basec);
RETURN VALUE
Both dirname and basename return pointers to null-terminated strings.
BUGS
In versions of glibc up to and including 2.2.1, dirname does not correctly handle pathnames with trailing '/' characters, and generates a
segmentation violation if given a NULL argument.
CONFORMING TO
SUSv2
SEE ALSO dirname(1), basename(1),
GNU 2000-12-14 DIRNAME(3)