Bash: How to replace a string in a directory recursively
Combine find, xargs and sed.
find . -name "*.css" | xargs sed -i 's/BEFORE/AFTER/g'
· admin
Combine find, xargs and sed.
find . -name "*.css" | xargs sed -i 's/BEFORE/AFTER/g'
Define a function echo_count and count the function name to be called in the script. You can refer to a variable ${TOTAL} .For example,
#!/bin/bash
export TARGET_DIR='./' # Current directory
export ORIGINAL_NAME='xxxxx'
export TARGET_NAME='yyyyy'
find "${TARGET_DIR}" -name '*${ORIGINAL_NAME}*' -execdir rename "s/${ORIGINAL_NAME}/${TARGET_NAME}/g" '{}' \;
\Drupal::request()->getHost()
This one doesn't include the URL that begins with https://〜, therefore you may want to write it as follows:
$hostname = sprintf('https://%s/', \Drupal::request()->getHost());
For example shown below, ['data'] requires after ['active'] like ['active']['data'].
Drupal 8 provides a useful helper funciton $entity->toLink(..). You must return it by converting to a string by using ->toString() at the end.
public function foo(Request $request = NULL) {
$id = $request->get('id'); // from query string
$entity = YourEntity::load($id);
$message = $this->t('Check at @url.', [
'@url' => $entity->toLink('<TEXT_TO_LINK_HERE>', 'edit-form')->toString(),
]);
return [
'#type' => 'markup',
'#markup' => $message,
];
}
You can output the current date and time as follows:
print \Drupal::service('date.formatter')->format((new \DateTime())->getTimeStamp(), 'short');
You cannot download a private key. You can only download the Server certs.
aws acm get-certificate --region us-east-1 --certificate-arn arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012
You can get the JSON output that contains the server and intermediate certs as follows:
Call the following static method\Drupal::service('uuid')->generate()
$uuid = \Drupal::service('uuid')->generate();
Put an Email address into $email that needs to be validated.
\Drupal::service('email.validator')->isValid($email);