.sh script to replace text
Hello all,
heres whats up: i'm trying to script a lil piece to execute in terminal so when i type something like: scriptname textfile the script searches the text file, replaces charecters of my choosing with charecters of my choosing "sed" im told is the way to go, and i got summat like this going Code:
#!/bin.sh the issue with the above code. . . how do i get it to target whatever text file follows the command? without having to manually designate sed to it each time? e.g. in commanding: scriptname textfile how do i get the script to target textfile^^^? much thanks, and obbvs, im a n00b. |
You can use $0 is your script to take place of the first argument.
Code:
#!/bin/bash |
Code:
#!/bin/bash |
Quote:
Code:
sed -i.backup -e s/char/newchar/g |
Code:
ruby -i.bakup -pne '$_.gsub!(/char/,"newchar");print' file |
All times are GMT -5. The time now is 05:24 PM. |