Single command to create a file and set its permission
install -m 777 /dev/null filename.txt
install -m 777 /dev/null filename.txt
You can use a here document: cat <<EOF >filename first line second line third line EOF You can place several of these in the same script.
printf ‘\x31\xc0\xc3′ | dd of=test_blob bs=1 seek=100 count=3 conv=notrunc dd arguments: of | file to patch bs | 1 byte at a time please seek | go to position 100 (decimal) conv=notrunc | don’t truncate the output after the edit (which dd does by default) One Josh looking out for another 😉
From the AWK man page: system(cmd) executes cmd and returns its exit status The GNU AWK manual also has a section that, in part, describes the system function and provides an example: system(“date | mail -s ‘awk run done’ root”)
hexdump -C does what you want. # hexdump -C /etc/passwd 00000000 72 6f 6f 74 3a 78 3a 30 3a 30 3a 72 6f 6f 74 3a |root:x:0:0:root:| 00000010 2f 72 6f 6f 74 3a 2f 62 69 6e 2f 62 61 73 68 0a |/root:/bin/bash.| 00000020 64 61 65 6d 6f 6e 3a 78 … Read more
Use one of these threee variants: SOME_PATH=”/mnt/someProject/some path” SOME_PATH=’/mnt/someProject/some path’ SOME_PATH=/mnt/someProject/some\ path
You can do it with either of these: sed ‘s/.*six.*/fault/’ file # check all lines sed ‘/six/s/.*/fault/’ file # matched lines -> then remove It gets the full line containing six and replaces it with fault. Example: $ cat file six asdf one two six one isix boo $ sed ‘s/.*six.*/fault/’ file fault asdf fault … Read more
To download release file from private repo, you can use Personal access token which can be generated at settings/tokens with Full control of private repositories scope. Then download the asset with curl command (change with appropriate values): curl -vLJO -H ‘Authorization: token my_access_token’ ‘https://api.github.com/repos/:owner/:repo/releases/assets/:id’ or if you’re using an OAuth app, use: curl -u my_client_id:my_client_secret … Read more
You can comment section of a script using a conditional. For example, the following script: DEBUG=false if ${DEBUG}; then echo 1 echo 2 echo 3 echo 4 echo 5 fi echo 6 echo 7 would output: 6 7 In order to uncomment the section of the code, you simply need to comment the variable: #DEBUG=false … Read more
The debug module could really use some love, but at the moment the best you can do is use this: – hosts: all gather_facts: no tasks: – shell: ps -eo pcpu,user,args | sort -r -k1 | head -n5 register: ps – debug: var=ps.stdout_lines It gives an output like this: ok: [host1] => { “ps.stdout_lines”: [ … Read more