New answers tagged

1

grep -l "gold" source.txt will output source.txt if the file contains the word gold xargs sed 's/green/red/' will run sed 's/green/red/' source.txt and the final redirect saves the result in your output. If I understand your intent correctly, you want the following command: sed -n '/gold/s/green/red/p' source.txt > pol.txt The /gold/ selects lines ...


3

To select any line containing gold from source.txt and replace the first occurrence of green with red: $ sed -n '/gold/{s/green/red/; p}' source.txt gold red white black blue To save that in a file: sed -n '/gold/{s/green/red/; p}' source.txt >pol.txt How it works -n tells sed not to print lines unless we explicitly ask it to. /gold/ selects ...


2

I do not know any particular method for dry run, but we can use some precautions for understanding an unknown script. Use a chroot environment to run your debug script. It will act as a sandbox and will provide protection against deleting/modifying main system files. Use bash -n <script> for syntax check. From gnu bash manual https://www.gnu.org/...


0

If you want your bash script (e.g. your executable .sh file) to kill the OS X Terminal application after the script execution is done, just add this line to the end of your script: kill `ps -A | grep -w Terminal.app | grep -v grep | awk '{print $1}'`


3

What you could do is the following: web.sh: #!/bin/bash systemctl $1 apache2 mysql The benefit of this solution is that you can do the following: sudo ./web.sh start to start everything. sudo ./web.sh stop to stop everything. sudo ./web.sh restart to restart. And so on...


0

You've only subscribed to the Changed event - this occurs when the content of a file is changed, or it is copied. This does not include files that are created or moved. May want to tinker to get the output how you want it, but the following should work: $source = "C:\Ops" $filter = "*.*" $fsw = New-Object System.IO.FileSystemWatcher $source, $filter -...


1

You may want to try changing the text "SELECTION" in the later part of the script to be "SECTION" to match the first part of the script. It looks like a simple spelling issue. So, this works for me: #This is where selection offers are added or removed #echo $'\n'$SELECTIONnumberNAME echo $'\n'$SECTION1NAME echo $'\n'$SECTION2NAME echo $'\n'$SECTION3NAME



Top 50 recent answers are included