10-29-2012
grepping files and then renaming file
Hi,
What is the easiest way to list a directory with 1000s of filenames, grep it for a certain sequence of numbers, and if found to rename the file by the value you are grepping.
eg
The file I am examining will looks like this:
1234
1224343
2324
244
35665
If I am examining a list of files in a given directory and grepping them for values in the file, if the value in the respective row is found to rename that file by the value of the row?
Thanks in advance
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello
i have the files in this format
pdb1i0t.ent
pdb1lv7.ent
pdb1pp6.ent
pdb1tj2.ent
pdb1xg2.ent
pdb2b4b.ent
pdb2ewe.ent
Now i have to remove the prefix pdb from all the files and also i need to change the extension of .ent to .txt
The new file should look like this
... (3 Replies)
Discussion started by: empyrean
3 Replies
2. Shell Programming and Scripting
Hi All,
I could use a bit of help with this as I'm at a loss.
I have a number of files all named accordingly:
I have a separate text file that is as follows:
What I want to do is end up with:
I don't know how to do this, though I'm certain it can be done, and would rather learn how... (14 Replies)
Discussion started by: Demosthenes
14 Replies
3. UNIX for Dummies Questions & Answers
Hi Guys,
I have a small problem of renaming multiple files. For example I have names of a set of files in one directory like
K2_34625-34675
K7_988963-988983
K12_773882-7734102
and the other set corresponding to the same is
U_P_321_9_3_11.ab1
U_P_322_9_3_11.ab1
U_P_323_9_3_11.ab1
Now... (23 Replies)
Discussion started by: pawannoel
23 Replies
4. Shell Programming and Scripting
got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies
5. Shell Programming and Scripting
Hi,
To all the Unix gurus this should be a simple task, but as a newbie I'm finding it hard to crack this. Any help is highly appreciated...
Scenario:
Step 1 : Move zip file from FTP folder to WORK folder
Step 2:
Unzip the file "Sample_YYYYMMDDHHMMSS.tar.gz" which contains many file... (10 Replies)
Discussion started by: asandy1234
10 Replies
6. Shell Programming and Scripting
Hi ,
I am kind of new to shell scripting and found a situation to handle ...
I have few files which will be ftpd in to our sustem , the file names needs to be renamed based on condition.
------------
Eg file names :-
AE_JUNFOR_2013_MTD_2013-04-09-08-30-09.TXT... (6 Replies)
Discussion started by: chillblue
6 Replies
7. Shell Programming and Scripting
Hi all,
Newbie here. First of all, sorry if I made any mistakes while posting this question in terms of rules. Correct me if I am wrong. :b:
I have a .dat file whose name is in the format of 20170311_abc_xyz.dat. The file consists of records whose first column consists of multiple dates in... (2 Replies)
Discussion started by: chanduris
2 Replies
8. Shell Programming and Scripting
Hi All,
I need to copy files from one directory to another with the files to be renamed while copying if a file with the same name already exists in the target directory.
THanks,
Dev (2 Replies)
Discussion started by: dev.devil.1983
2 Replies
9. UNIX for Beginners Questions & Answers
Hello Gurus,
I have a requirement to split the xml file into different xml files.
Can you please help me with that?
Here is my Source XML file
<jms-system-resource>
<name>PS6SOAJMSModule</name>
<target>soa_server1</target>
<sub-deployment>
... (3 Replies)
Discussion started by: Siv51427882
3 Replies
10. UNIX for Beginners Questions & Answers
Greetings. I am working in a Linux environment and am trying to figure out a way to rename files in a directory by appending a unique strings that appears within a certain area in those files. I have gotten as far as identifying what that particular unique string is with a command like the... (10 Replies)
Discussion started by: HLee1981
10 Replies
LEARN ABOUT DEBIAN
renameat
RENAMEAT(2) Linux Programmer's Manual RENAMEAT(2)
NAME
renameat - rename a file relative to directory file descriptors
SYNOPSIS
#include <fcntl.h> /* Definition of AT_* constants */
#include <stdio.h>
int renameat(int olddirfd, const char *oldpath,
int newdirfd, const char *newpath);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
renameat():
Since glibc 2.10:
_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
Before glibc 2.10:
_ATFILE_SOURCE
DESCRIPTION
The renameat() system call operates in exactly the same way as rename(2), except for the differences described in this manual page.
If the pathname given in oldpath is relative, then it is interpreted relative to the directory referred to by the file descriptor olddirfd
(rather than relative to the current working directory of the calling process, as is done by rename(2) for a relative pathname).
If oldpath is relative and olddirfd is the special value AT_FDCWD, then oldpath is interpreted relative to the current working directory of
the calling process (like rename(2)).
If oldpath is absolute, then olddirfd is ignored.
The interpretation of newpath is as for oldpath, except that a relative pathname is interpreted relative to the directory referred to by
the file descriptor newdirfd.
RETURN VALUE
On success, renameat() returns 0. On error, -1 is returned and errno is set to indicate the error.
ERRORS
The same errors that occur for rename(2) can also occur for renameat(). The following additional errors can occur for renameat():
EBADF olddirfd or newdirfd is not a valid file descriptor.
ENOTDIR
oldpath is relative and olddirfd is a file descriptor referring to a file other than a directory; or similar for newpath and
newdirfd
VERSIONS
renameat() was added to Linux in kernel 2.6.16; library support was added to glibc in version 2.4.
CONFORMING TO
POSIX.1-2008.
NOTES
See openat(2) for an explanation of the need for renameat().
SEE ALSO
openat(2), rename(2), path_resolution(7)
COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2012-05-04 RENAMEAT(2)