Insidethe.com

Insidethe.com

Random Life and Technology Bits

RegEx To Find Lines Containing Text and Exclude Matches Containing Text

 

This is an example of how to do a find in files with PhpStorm or WebStorm but exclude lines matching a specific string.

For example, give this code below, we want to find all lines that contain the http://example.com/api but do not also contain the string ‘some_variable’

$my_url = variable_get("some_variable", "http://example.com/api");
...
$my_url = 'http://example.com/api';

The RegEx pattern will find all lines that contain the URL but exclude the lines with the specified text:

^(?!.*some_variable.*$).*(http:\/\/example.com\/api)

This should work in any JetBrains editor which supports Java regular expressions.

Rescan For Disks Without Rebooting

for host in /sys/class/scsi_host/*; do echo "- - -" | sudo tee $host/scan; ls /dev/sd* ; done

Source:
https://unix.stackexchange.com/questions/404405/how-to-detect-new-hard-disk-attached-without-rebooting/500280#500280?s=a878dbdf0ffd4699bcb88957b7c1c087