Script for update

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have a script used for update :



OLD="int 10"
NEW="int 20"
i=0
DPATH="/home"

for f in $DPATH
do
sed -i "s/$OLD/$NEW/g" $f
let i++
echo "modified:" $f
done


what i need according to my old value have the path where i can change OLD to NEW (for update)










share|improve this question























  • Would you like to rename the files in DPATH or modify the contents of certain files in DPATH. Some examples would help.
    – rahul
    Apr 29 '15 at 14:57










  • i want to modify the contents of txt file in DPATH my value OLD is in many txt file in DPATH so i want to have this path to do the update .Thanks for your help
    – toto
    Apr 29 '15 at 15:02














up vote
0
down vote

favorite












I have a script used for update :



OLD="int 10"
NEW="int 20"
i=0
DPATH="/home"

for f in $DPATH
do
sed -i "s/$OLD/$NEW/g" $f
let i++
echo "modified:" $f
done


what i need according to my old value have the path where i can change OLD to NEW (for update)










share|improve this question























  • Would you like to rename the files in DPATH or modify the contents of certain files in DPATH. Some examples would help.
    – rahul
    Apr 29 '15 at 14:57










  • i want to modify the contents of txt file in DPATH my value OLD is in many txt file in DPATH so i want to have this path to do the update .Thanks for your help
    – toto
    Apr 29 '15 at 15:02












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a script used for update :



OLD="int 10"
NEW="int 20"
i=0
DPATH="/home"

for f in $DPATH
do
sed -i "s/$OLD/$NEW/g" $f
let i++
echo "modified:" $f
done


what i need according to my old value have the path where i can change OLD to NEW (for update)










share|improve this question















I have a script used for update :



OLD="int 10"
NEW="int 20"
i=0
DPATH="/home"

for f in $DPATH
do
sed -i "s/$OLD/$NEW/g" $f
let i++
echo "modified:" $f
done


what i need according to my old value have the path where i can change OLD to NEW (for update)







linux bash scripting grep updatedb






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 at 9:26









Rui F Ribeiro

38.2k1475123




38.2k1475123










asked Apr 29 '15 at 14:54









toto

59138




59138











  • Would you like to rename the files in DPATH or modify the contents of certain files in DPATH. Some examples would help.
    – rahul
    Apr 29 '15 at 14:57










  • i want to modify the contents of txt file in DPATH my value OLD is in many txt file in DPATH so i want to have this path to do the update .Thanks for your help
    – toto
    Apr 29 '15 at 15:02
















  • Would you like to rename the files in DPATH or modify the contents of certain files in DPATH. Some examples would help.
    – rahul
    Apr 29 '15 at 14:57










  • i want to modify the contents of txt file in DPATH my value OLD is in many txt file in DPATH so i want to have this path to do the update .Thanks for your help
    – toto
    Apr 29 '15 at 15:02















Would you like to rename the files in DPATH or modify the contents of certain files in DPATH. Some examples would help.
– rahul
Apr 29 '15 at 14:57




Would you like to rename the files in DPATH or modify the contents of certain files in DPATH. Some examples would help.
– rahul
Apr 29 '15 at 14:57












i want to modify the contents of txt file in DPATH my value OLD is in many txt file in DPATH so i want to have this path to do the update .Thanks for your help
– toto
Apr 29 '15 at 15:02




i want to modify the contents of txt file in DPATH my value OLD is in many txt file in DPATH so i want to have this path to do the update .Thanks for your help
– toto
Apr 29 '15 at 15:02










1 Answer
1






active

oldest

votes

















up vote
0
down vote













You can use this script:



#!/bin/bash
OLD="int 10"
NEW="int 20"

for file in /home/a/*; do
[[ -f $file ]] && sed -i "s/$OLD/$NEW/g" "$file" && echo "modified: $file"
done





share|improve this answer






















  • i have this error sed: couldn't edit /home/a/b: not a regular file I think the problem that they can't have the subdirectory
    – toto
    Apr 29 '15 at 15:33










  • @toto: Check my edits..you were getting the eroor because /home/a/b is a direcotiry..now we are considering regular files only..
    – heemayl
    Apr 29 '15 at 15:37










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f199424%2fscript-for-update%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You can use this script:



#!/bin/bash
OLD="int 10"
NEW="int 20"

for file in /home/a/*; do
[[ -f $file ]] && sed -i "s/$OLD/$NEW/g" "$file" && echo "modified: $file"
done





share|improve this answer






















  • i have this error sed: couldn't edit /home/a/b: not a regular file I think the problem that they can't have the subdirectory
    – toto
    Apr 29 '15 at 15:33










  • @toto: Check my edits..you were getting the eroor because /home/a/b is a direcotiry..now we are considering regular files only..
    – heemayl
    Apr 29 '15 at 15:37














up vote
0
down vote













You can use this script:



#!/bin/bash
OLD="int 10"
NEW="int 20"

for file in /home/a/*; do
[[ -f $file ]] && sed -i "s/$OLD/$NEW/g" "$file" && echo "modified: $file"
done





share|improve this answer






















  • i have this error sed: couldn't edit /home/a/b: not a regular file I think the problem that they can't have the subdirectory
    – toto
    Apr 29 '15 at 15:33










  • @toto: Check my edits..you were getting the eroor because /home/a/b is a direcotiry..now we are considering regular files only..
    – heemayl
    Apr 29 '15 at 15:37












up vote
0
down vote










up vote
0
down vote









You can use this script:



#!/bin/bash
OLD="int 10"
NEW="int 20"

for file in /home/a/*; do
[[ -f $file ]] && sed -i "s/$OLD/$NEW/g" "$file" && echo "modified: $file"
done





share|improve this answer














You can use this script:



#!/bin/bash
OLD="int 10"
NEW="int 20"

for file in /home/a/*; do
[[ -f $file ]] && sed -i "s/$OLD/$NEW/g" "$file" && echo "modified: $file"
done






share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 29 '15 at 15:36

























answered Apr 29 '15 at 15:13









heemayl

34k370100




34k370100











  • i have this error sed: couldn't edit /home/a/b: not a regular file I think the problem that they can't have the subdirectory
    – toto
    Apr 29 '15 at 15:33










  • @toto: Check my edits..you were getting the eroor because /home/a/b is a direcotiry..now we are considering regular files only..
    – heemayl
    Apr 29 '15 at 15:37
















  • i have this error sed: couldn't edit /home/a/b: not a regular file I think the problem that they can't have the subdirectory
    – toto
    Apr 29 '15 at 15:33










  • @toto: Check my edits..you were getting the eroor because /home/a/b is a direcotiry..now we are considering regular files only..
    – heemayl
    Apr 29 '15 at 15:37















i have this error sed: couldn't edit /home/a/b: not a regular file I think the problem that they can't have the subdirectory
– toto
Apr 29 '15 at 15:33




i have this error sed: couldn't edit /home/a/b: not a regular file I think the problem that they can't have the subdirectory
– toto
Apr 29 '15 at 15:33












@toto: Check my edits..you were getting the eroor because /home/a/b is a direcotiry..now we are considering regular files only..
– heemayl
Apr 29 '15 at 15:37




@toto: Check my edits..you were getting the eroor because /home/a/b is a direcotiry..now we are considering regular files only..
– heemayl
Apr 29 '15 at 15:37

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f199424%2fscript-for-update%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay