•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 397,616 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,416 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 18719 | Replies: 3
![]() |
•
•
Join Date: Apr 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hey guys, i am about to throw it all in because i just cannot get this to work
.
All i wanted to do is search through a file and find a string and replace with an argument from the command line.
So basically i have a file which has the contents of :
this is a test file
yes i am cool
say if i want to replace cool with $1 (which is 'crap', an argument from the shell) how do i accomplish this?
So far i have $1 = awk '/yes/ { print $4 }' file > file
I then want to overwrite the file with the updated contents. So the contents of file look like this:
this is a test file
yes i am crap
This just doesnt seem to do the job. If anyone knows please help!! i wont have any fingernails left soon
thanks guys.
.All i wanted to do is search through a file and find a string and replace with an argument from the command line.
So basically i have a file which has the contents of :
this is a test file
yes i am cool
say if i want to replace cool with $1 (which is 'crap', an argument from the shell) how do i accomplish this?
So far i have $1 = awk '/yes/ { print $4 }' file > file
I then want to overwrite the file with the updated contents. So the contents of file look like this:
this is a test file
yes i am crap
This just doesnt seem to do the job. If anyone knows please help!! i wont have any fingernails left soon
thanks guys. ![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
- Writing text from textbox to file... (C++)
- Replacing text (Shell Scripting)
- Output to text (notepad) file (HTML and CSS)
Other Threads in the Shell Scripting Forum
- Previous Thread: Automating an FTP upload
- Next Thread: How to insert new argument into the middle of a file


Linear Mode