for loop not working in bashParse two files input in for/while loopfor loop to iterate through some file nth positionHow to use 3rd variable in BASH for loop?how can we use multiple variables in single for loop in shell script?Infinite Loop in Nested For Loopwhile loop to check for user input not in for loopBegin for loop every time where it ended lastFor loop not working in a function with arguments

Does a face-down creature with morph retain its damage when it is turned face up?

Science fiction short story where aliens contact a drunk about Earth's impending destruction

Algorithms vs LP or MIP

Can pay be witheld for hours cleaning up after closing time?

for loop not working in bash

How should I face my manager if I make a mistake because a senior coworker explained something incorrectly to me?

Can realistic planetary invasion have any meaningful strategy?

Are illustrations in novels frowned upon?

Why is my Earth simulation slower than the reality?

Why does The Ancient One think differently about Doctor Strange in Endgame than the film Doctor Strange?

Earth rotation discrepancy

I have a player who yells

Are there account age or level requirements for obtaining special research?

Numbers Decrease while Letters Increase

Irish Snap: Variant Rules

Does norwegian.no airline overbook flights?

Is using a hyperlink to close a modal a poor design decision?

Cross-referencing enumerate item

What is wrong about this application of Kirchhoffs Current Law?

Does acid dissolve PETG 3D prints?

Dealing with an extrovert co-worker

Is there a known non-euclidean geometry where two concentric circles of different radii can intersect? (as in the novel "The Universe Between")

Compelling story with the world as a villain

Avoiding racist tropes in fantasy



for loop not working in bash


Parse two files input in for/while loopfor loop to iterate through some file nth positionHow to use 3rd variable in BASH for loop?how can we use multiple variables in single for loop in shell script?Infinite Loop in Nested For Loopwhile loop to check for user input not in for loopBegin for loop every time where it ended lastFor loop not working in a function with arguments






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















i have the below code to replace some strigns in multiple files, but the for loop is checking for the first file and not executing the perl script. below is my code



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in $(./zebu.work.post_opt/ZEBU_CTO_FT_MOD*);
do
perl -i -p -e 's/input/inout/g' $file;
perl -i -p -e 's/output/inout/g' $file;
perl -i -p -e 's/wire.*n/tran(i0, o);/g' $file;
perl -i -p -e 's/assign.*n//g' $file;
done
fi









share|improve this question









New contributor



sudhir prabhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Remove the $(...) around your filename globbing pattern. You don't need a command substitution there. You may also combine the four Perl invocations to a single one for speed.

    – Kusalananda
    8 hours ago


















4















i have the below code to replace some strigns in multiple files, but the for loop is checking for the first file and not executing the perl script. below is my code



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in $(./zebu.work.post_opt/ZEBU_CTO_FT_MOD*);
do
perl -i -p -e 's/input/inout/g' $file;
perl -i -p -e 's/output/inout/g' $file;
perl -i -p -e 's/wire.*n/tran(i0, o);/g' $file;
perl -i -p -e 's/assign.*n//g' $file;
done
fi









share|improve this question









New contributor



sudhir prabhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Remove the $(...) around your filename globbing pattern. You don't need a command substitution there. You may also combine the four Perl invocations to a single one for speed.

    – Kusalananda
    8 hours ago














4












4








4








i have the below code to replace some strigns in multiple files, but the for loop is checking for the first file and not executing the perl script. below is my code



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in $(./zebu.work.post_opt/ZEBU_CTO_FT_MOD*);
do
perl -i -p -e 's/input/inout/g' $file;
perl -i -p -e 's/output/inout/g' $file;
perl -i -p -e 's/wire.*n/tran(i0, o);/g' $file;
perl -i -p -e 's/assign.*n//g' $file;
done
fi









share|improve this question









New contributor



sudhir prabhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











i have the below code to replace some strigns in multiple files, but the for loop is checking for the first file and not executing the perl script. below is my code



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in $(./zebu.work.post_opt/ZEBU_CTO_FT_MOD*);
do
perl -i -p -e 's/input/inout/g' $file;
perl -i -p -e 's/output/inout/g' $file;
perl -i -p -e 's/wire.*n/tran(i0, o);/g' $file;
perl -i -p -e 's/assign.*n//g' $file;
done
fi






bash for






share|improve this question









New contributor



sudhir prabhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



sudhir prabhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 8 hours ago









pLumo

7,45814 silver badges33 bronze badges




7,45814 silver badges33 bronze badges






New contributor



sudhir prabhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 8 hours ago









sudhir prabhusudhir prabhu

211 bronze badge




211 bronze badge




New contributor



sudhir prabhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




sudhir prabhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 1





    Remove the $(...) around your filename globbing pattern. You don't need a command substitution there. You may also combine the four Perl invocations to a single one for speed.

    – Kusalananda
    8 hours ago













  • 1





    Remove the $(...) around your filename globbing pattern. You don't need a command substitution there. You may also combine the four Perl invocations to a single one for speed.

    – Kusalananda
    8 hours ago








1




1





Remove the $(...) around your filename globbing pattern. You don't need a command substitution there. You may also combine the four Perl invocations to a single one for speed.

– Kusalananda
8 hours ago






Remove the $(...) around your filename globbing pattern. You don't need a command substitution there. You may also combine the four Perl invocations to a single one for speed.

– Kusalananda
8 hours ago











1 Answer
1






active

oldest

votes


















7















The $(foo) construct will run the command foo and replace $(foo) with the output of running foo. You want a glob, that's not a command. What you're doing is attempting to run all files called ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*. All you need is:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g' "$file"
perl -i -p -e 's/output/inout/g' "$file"
perl -i -p -e 's/wire.*n/tran(i0, o);/g' "$file"
perl -i -p -e 's/assign.*n//g' "$file"
done
fi


Or, more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' "$file"
done
fi


Or even more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*
fi





share|improve this answer






















  • 1





    Is the loop even needed? Can perl -ip work on several files at once? I've never tested taht.

    – Kusalananda
    8 hours ago












  • @Kusalananda indeed it can. Should have thought of that, thanks!

    – terdon
    8 hours ago













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',
autoActivateHeartbeat: false,
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
);



);






sudhir prabhu is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f536882%2ffor-loop-not-working-in-bash%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









7















The $(foo) construct will run the command foo and replace $(foo) with the output of running foo. You want a glob, that's not a command. What you're doing is attempting to run all files called ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*. All you need is:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g' "$file"
perl -i -p -e 's/output/inout/g' "$file"
perl -i -p -e 's/wire.*n/tran(i0, o);/g' "$file"
perl -i -p -e 's/assign.*n//g' "$file"
done
fi


Or, more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' "$file"
done
fi


Or even more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*
fi





share|improve this answer






















  • 1





    Is the loop even needed? Can perl -ip work on several files at once? I've never tested taht.

    – Kusalananda
    8 hours ago












  • @Kusalananda indeed it can. Should have thought of that, thanks!

    – terdon
    8 hours ago















7















The $(foo) construct will run the command foo and replace $(foo) with the output of running foo. You want a glob, that's not a command. What you're doing is attempting to run all files called ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*. All you need is:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g' "$file"
perl -i -p -e 's/output/inout/g' "$file"
perl -i -p -e 's/wire.*n/tran(i0, o);/g' "$file"
perl -i -p -e 's/assign.*n//g' "$file"
done
fi


Or, more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' "$file"
done
fi


Or even more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*
fi





share|improve this answer






















  • 1





    Is the loop even needed? Can perl -ip work on several files at once? I've never tested taht.

    – Kusalananda
    8 hours ago












  • @Kusalananda indeed it can. Should have thought of that, thanks!

    – terdon
    8 hours ago













7














7










7









The $(foo) construct will run the command foo and replace $(foo) with the output of running foo. You want a glob, that's not a command. What you're doing is attempting to run all files called ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*. All you need is:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g' "$file"
perl -i -p -e 's/output/inout/g' "$file"
perl -i -p -e 's/wire.*n/tran(i0, o);/g' "$file"
perl -i -p -e 's/assign.*n//g' "$file"
done
fi


Or, more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' "$file"
done
fi


Or even more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*
fi





share|improve this answer















The $(foo) construct will run the command foo and replace $(foo) with the output of running foo. You want a glob, that's not a command. What you're doing is attempting to run all files called ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*. All you need is:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g' "$file"
perl -i -p -e 's/output/inout/g' "$file"
perl -i -p -e 's/wire.*n/tran(i0, o);/g' "$file"
perl -i -p -e 's/assign.*n//g' "$file"
done
fi


Or, more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
for file in ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*;
do
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' "$file"
done
fi


Or even more simply:



if [ -f zebu.work.post_opt/ZEBU_CTO_FT_MOD.v ]
then
perl -i -p -e 's/input/inout/g; s/output/inout/g;
s/wire.*n/tran(i0, o);/g;
s/assign.*n//g' ./zebu.work.post_opt/ZEBU_CTO_FT_MOD*
fi






share|improve this answer














share|improve this answer



share|improve this answer








edited 8 hours ago









Kusalananda

160k18 gold badges318 silver badges504 bronze badges




160k18 gold badges318 silver badges504 bronze badges










answered 8 hours ago









terdonterdon

141k34 gold badges290 silver badges468 bronze badges




141k34 gold badges290 silver badges468 bronze badges










  • 1





    Is the loop even needed? Can perl -ip work on several files at once? I've never tested taht.

    – Kusalananda
    8 hours ago












  • @Kusalananda indeed it can. Should have thought of that, thanks!

    – terdon
    8 hours ago












  • 1





    Is the loop even needed? Can perl -ip work on several files at once? I've never tested taht.

    – Kusalananda
    8 hours ago












  • @Kusalananda indeed it can. Should have thought of that, thanks!

    – terdon
    8 hours ago







1




1





Is the loop even needed? Can perl -ip work on several files at once? I've never tested taht.

– Kusalananda
8 hours ago






Is the loop even needed? Can perl -ip work on several files at once? I've never tested taht.

– Kusalananda
8 hours ago














@Kusalananda indeed it can. Should have thought of that, thanks!

– terdon
8 hours ago





@Kusalananda indeed it can. Should have thought of that, thanks!

– terdon
8 hours ago










sudhir prabhu is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















sudhir prabhu is a new contributor. Be nice, and check out our Code of Conduct.












sudhir prabhu is a new contributor. Be nice, and check out our Code of Conduct.











sudhir prabhu is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f536882%2ffor-loop-not-working-in-bash%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

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її