troubleshooting Question

Bash script with a parameter

Avatar of Simon336697
Simon336697Flag for Australia asked on
LinuxLinux Distributions
8 Comments1 Solution490 ViewsLast Modified:
Hi guys!

If I wanted to change the sed_replace.sh below so I did not have to hardcode the filename, but could issue the filename with a wildard to act on in the for part of the script, would you guys know how i could change my current script?

=========================================== current sed_replace.sh

      1 #! /bin/bash
      2 for text in *menu4_it_sware_videogalleries_*.php; do
      3 mv $text $text.old
      4 sed 's/\.\.\/\.\.\///g' $text.old > $text
      5 rm -f $text.old
      6 done
========================================================

So, instead of just running....

sed_replace.sh

which would find only files of type *menu4_it_sware_videogalleries_*.php,

The script could "somehow be modified" to let you place a parameter after the script name and it will act on that in the for statement of the script...
For example:

sed_replace.sh *menu2_it_drp_webcasts_*.php
or
sed_replace.sh *menu2_it_backup_highslides_*.php

Any help appreciated.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros