Sponsored Content
Top Forums Shell Programming and Scripting To replace a string in file by its parent folder name. Post 302479141 by R0H0N on Friday 10th of December 2010 01:05:23 AM
Old 12-10-2010
Code:
for file in `find /folder1 -type f -name "file.php" | xargs`     # This will list ot the files and if file name is not static then use "*.php"
do
    website=`echo "$file" | cut -d"\/" -f3`               # Extract website name
    sed -e 's/string/$website/g' $file                      # Substitute particular string with website name
done

This User Gave Thanks to For This Post:
R0H0N
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I search parent folder only?

I have a directory /dir1/dir2/dir3/dir4/dir5. How can I search for files only in dir4/ and not in dir5? I tried the maxdepth command, but it doesn't work in this flavor of sun OS. When I search for files in dir4, it's giving me results from dir5 as well. I don't want this. Thanks. (3 Replies)
Discussion started by: bbbngowc
3 Replies

2. Shell Programming and Scripting

Replace string in all files in a folder and subfolders.

i need to change string in all files in current folder and all subfolders. i wrote the following script. It works good except it dont delete temp file from subfolders. for z in `find . -type f -name "*.html" -o -name "*.htm"`; do sed -e 's@abc@xyz@g' $z>temp; mv temp $z; done any idea?... (1 Reply)
Discussion started by: crazynups
1 Replies

3. Shell Programming and Scripting

full path of a file situated either in parent's dir. or parent's parent dir. so on...

hi experts(novice people can stay away as it is no child's game), i am developing a script which works like recycle bin of windows. the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to... (1 Reply)
Discussion started by: yahoo!
1 Replies

4. Shell Programming and Scripting

How to read a subfolder one by one in parent folder?

Hi friends, I am getting some trubles in folder reading. I am having 10 subfolders inside server7 folder. i wanna to read a subfolder name first and check if the foldername gets started with "http". if so , i need to read a file inside that folder. This willl continue for... (1 Reply)
Discussion started by: kamatchirajan
1 Replies

5. Shell Programming and Scripting

Replace last 2 folder directory string with sed

Hi guys, I´m trying to replace the 2 last folders name in a list of directories with a new string, but I´m don´t know which regex to apply. Directories list: C/my user/documents/games & music C/my user/documents/photos 09-24-2008 C/my user/settings/config ?1_2 * The last folder may have... (11 Replies)
Discussion started by: cgkmal
11 Replies

6. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

7. UNIX for Dummies Questions & Answers

Grep with parent folder

Hi, When I do ls -l | grep -h STRING I need not only to get those files, but also the parent folder of those files, no idea how do that. BTW the names of those parent folders are never longer than 3 digits, if that helps. Any assistance most welcome, /bw, OmarKN Please... (9 Replies)
Discussion started by: OmarKN
9 Replies

8. Shell Programming and Scripting

Move parent folder if contents match a parameter

Hi all, Hoping someone can help. I'm looking to be able to search a particular folder path for folders that contain certain files / formats and then move the parent folder. eg. /foo/bar/folder1/file.exe /foo/bar/folder2/file.exe and then move the folder1/2 tp another folder. So if... (1 Reply)
Discussion started by: springs2
1 Replies

9. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

10. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies
Finance::Quote::IndiaMutual(3)				User Contributed Perl Documentation			    Finance::Quote::IndiaMutual(3)

NAME
Finance::Quote::IndiaMutual - Obtain Indian mutual fund prices from amfiindia.com SYNOPSIS
use Finance::Quote; $q = Finance::Quote->new; %stockinfo = $q->fetch("indiamutual", "amfiindia-code"); # Can failover to other methods %stockinfo = $q->fetch("amfiindia", "amfiindia-code"); # Use this module only. # NOTE: currently no failover methods exist for indiamutual DESCRIPTION
This module obtains information about Indian Mutual Fund prices from the Association of Mutual Funds India website amfiindia.com. The information source "indiamutual" can be used if the source of prices is irrelevant, and "amfiindia" if you specifically want to use information downloaded from amfiindia.com. AMFIINDIA-CODE In India a mutual fund does not have a unique global symbol identifier. This module uses an id that represents the mutual fund on an id used by amfiindia.com. You can the fund is from the AMFI web site http://amfiindia.com/downloadnavopen.asp. LABELS RETURNED
Information available from amfiindia may include the following labels: method link source name currency nav rprice sprice. The link label will be a url location for the NAV list table for all funds. NOTES
amfiindia.com provides a link to download a text file containing all the NAVs. This file is mirrored in a local file /tmp/amfinavlist.txt. The local mirror serves only as a cache and can be safely removed. Currently NAVs of Open-Ended funds are supported. SEE ALSO
AMFI india website - http://amfiindia.com/ Finance::Quote perl v5.12.1 2009-10-05 Finance::Quote::IndiaMutual(3)
All times are GMT -4. The time now is 10:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy