11-29-2011
how to find files and replace them in a directory in Shell scripting
I have a directory /java/unix/data
In data directory i have so many files from which i want to find some files who look alike below.(there are number of such below such files as well different files too in the data directory)
-68395#svg.xml
-56789#ghi.xml
-67894#gjk.org
-56734#gil.txt
I need to find all the such files having above file names as mentioned above and want to replace or cut them.
Expected Output:
I mean i want the files to renamed and processed in the same directory as below:
/java/unix/data
svg.xml
ghi.xml
ghk.org
gil.txt
I mean to say anything which can cut them on the the basis of (#)
Last edited by vbe; 11-29-2011 at 01:45 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi guys,
Suppose you have 100 files in a folder and you want to replace all occurances of a word say "ABCD" in those files with "DCBA", how would you do
it ???
jatin (13 Replies)
Discussion started by: jatins_s
13 Replies
2. Shell Programming and Scripting
Hi All,
I am new to UNIX. I will be thankful if some one helps me.
I have to write a shell script for one of the requirement.
I have files created from Jan 2006 to March 2008.
My requirement is to write a script in such a way that
1) To find and copy(not Moving) the files created in the... (2 Replies)
Discussion started by: manas6
2 Replies
3. Shell Programming and Scripting
Hi,
I have a directory has DIR1 and the D1 directory has 200+ files.
I want change the string from "Bangalore" to "Bangaluru" in all files in the D1 directory.
Thanks (2 Replies)
Discussion started by: koti_rama
2 Replies
4. Shell Programming and Scripting
I'm looking to write a ksh code with will be alble to find a word like 'toto' in all files going from my current directory.
eg.
/doc ----------->have: text.c which "toto"
/doc/usr-------->have: build.pc, help.java which "toto"
/doc/usr/cach -->have: test.sh which "toto"
/doc/build... (4 Replies)
Discussion started by: yeclota
4 Replies
5. Shell Programming and Scripting
I used the following script
cd pathname
for y in `ls *`;
do sed "s/ABCD/DCBA/g" $y > temp; mv temp $y;
done
and it worked fine for finding and replacing strings with names etc. in all files of the given path.
I'm trying to replace a string which consists of path (location of file)
... (11 Replies)
Discussion started by: pharos467
11 Replies
6. UNIX for Dummies Questions & Answers
Hi all,
I'm looking to find and replace a string in all HTML files within a certain directory, including subdirectories. Normally, I would play with this a little to get it to work, but I can't mess this up, so I'm going to ask here.
Basically, I want to find "<title>" in all *.htm* files... (11 Replies)
Discussion started by: slothario
11 Replies
7. Shell Programming and Scripting
Hi all
This is my first post. Please bear with me with all my mistakes. I started learning shell since couple of days now and this might be quite basic for all, i want to search for files in a directory containing specific string and replace it with new string. The code i wrote is quite bulky... (2 Replies)
Discussion started by: theprogrammer
2 Replies
8. Shell Programming and Scripting
Hi,
i need help on shell scripting.
Main intention of the script is
step 1: ssh to remote server
Step 2: cd /tmp in remote server
Step 3: in tmp i want to grep only files and directories which are in GB sizes
All the servers list file is - tmpsrv.txt
vi tmpsrv.txt
... (17 Replies)
Discussion started by: kumar85shiv
17 Replies
9. Shell Programming and Scripting
Hi,
The requirement is below:
There are 5 files in a unix directory and i need to pick up latest file from the directory that i can do like this ls -lrt | tail -1 and this file can be processed. now the actual requirement is some times what will happen the second third...on files i.e(ls -lrt... (4 Replies)
Discussion started by: prawinmca
4 Replies
10. Shell Programming and Scripting
I need help to write shell script to copy files from one server to another server.
Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies
LEARN ABOUT DEBIAN
flvtool2
FLVTOOL2(1) General Commands Manual FLVTOOL2(1)
NAME
flvtool2 - a manipulation tool for flash video files
SYNOPSIS
flvtool2 [-ACDPUVaciklnoprstvx]...[-key:value]...in-path|stdin[out-path|stdout]
DESCRIPTION
If out-path is omitted, in-path will be overwritten. In-path can be a single file, or a directory. If in-path is a directory, out-path has
to be likewise, or can be omitted. Directory recursion is controlled by the -r switch. You can use stdin and stdout keywords as in- and
out-path for piping or redirecting.
Chain commands like that: -UP (updates FLV file than prints out meta data)
COMMANDS
-A Adds tags from -t tags-file
-C Cuts file using -i inpoint and -o outpoint
-D Debugs file (writes a lot to stdout)
-H Helpscreen will be shown
-P Prints out meta data to stdout
-U Updates FLV with an onMetaTag event
SWITCHES
-a Collapse space between cut regions
-c Compatibility mode calculates some onMetaTag values differently
-key:value
Key-value-pair for onMetaData tag (overwrites generated values)
-i timestamp
Inpoint for cut command in miliseconds
-k Keyframe mode slides onCuePoint(navigation) tags added by the add command to nearest keyframe position
-l Logs FLV stream reading to stream.log in current directory
-n Number of tag to debug
-o timestamp
Outpoint for cut command in miliseconds
-p Preserve mode only updates FLVs that have not been processed before
-r Recursion for directory processing
-s Simulation mode never writes FLV data to out-path
-t path
Tagfile (MetaTags written in XML)
-v Verbose mode
-x XML mode instead of YAML mode
SEE ALSO
/usr/share/doc/flvtool2/examples/tags.xml
http://www.inlet-media.de/flvtool2
AUTHOR
flvtool2 was written by Norman Timmler <norman.timmler@inlet-media.de>
This manual page was written by Todd Troxell <ttroxell@debian.org>, for the Debian project (but may be used by others).
August 24, 2007 FLVTOOL2(1)