This is how Unix SED was meant to be used.
Take a text file and substitute 1 regex match for a new one, in place.
My file:
-rw-r--r-- 1 matt matt 7338 May 6 00:05 merge.rb
sed -i s/OLDVALUE/NEWVALUE/g merge.rb
-i means in-place
-s means substitute
-g means globally
Matt Feenstra is an Architect and Developer, living and working in Palm Desert, CA
Monday, May 6, 2019
Friday, May 3, 2019
Ruby - How to make your program run from any directory (with libraries)
#!/usr/bin/ruby
### Save the folder name that this lives in
folder = File.expand_path('.',__dir__)
### Add to the Ruby default load path the pwd this was executed from
$LOAD_PATH.unshift(folder) unless $LOAD_PATH.include?(folder)
### Here we can now interpolate a relative path
load "#{folder}/../lib/modules.rb"
puts "stub.rb pwd: #{Dir.pwd}"
Subscribe to:
Posts (Atom)