Last active
June 5, 2018 13:49
-
-
Save s-leroux/42377061175b9c323bf5feb2d81bdb65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tweet.*.txt | |
tweet.*.yaml | |
xx* | |
EXAMPLE-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! INIT | |
PS1="sh$ " | |
rm -f tweet.*.yaml | |
rm -f tweet.*.txt | |
rm -f tweet.??? | |
rm -f xx?? | |
echo BEGIN | |
#! POST | |
sed -E -e '1,/^BEGIN$/d' -e '/^sh\$ exit$/d' -e 's/^sh\$[ \t]*$//' | |
#= EXAMPLE-0 | |
awk < tweets.yaml ' | |
/----/ { OUTPUT="tweet." (N++) ".yaml" } | |
{ print > OUTPUT } | |
' | |
ls -l tweet.*.yaml | |
#= EXAMPLE-1 | |
# tag::A[] | |
csplit tweets.yaml /----/ | |
#end::A[] | |
# tag::B[] | |
ls -l xx0* | |
#end::B[] | |
#= EXAMPLE-2 | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
/----/ | |
ls -l tweet.* | |
#= EXAMPLE-3 | |
rm tweet.* | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
/----/ | |
ls -l tweet.* | |
#= EXAMPLE-4 | |
# tag::A[] | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
/----/ /----/ /----/ | |
# end::A[] | |
# tag::B[] | |
ls -l tweet.???.yaml | |
# end::B[] | |
#= EXAMPLE-5 | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
/----/ '{*}' | |
#= EXAMPLE-6A | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
/----/ '{6}' | |
#= EXAMPLE-7A | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
/----/ '{999}' | |
ls tweet.* | |
#= EXAMPLE-7B | |
touch tweet.002.yaml | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
/----/ '{999}' | |
ls tweet.* | |
#= EXAMPLE-8A | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
--keep-files \ | |
/----/ '{999}' | |
ls tweet.* | |
#= EXAMPLE-8B | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
--keep-files \ | |
/----/ '{999}' | |
# tag::A[] | |
diff -s tweets.yaml <(cat tweet.*) | |
# end::A[] | |
#= EXAMPLE-9A | |
csplit tweets.txt \ | |
--prefix='tweet.' --suffix-format='%03d.txt' \ | |
--elide-empty-files \ | |
--keep-files \ | |
2 '{*}' | |
#= EXAMPLE-9B | |
csplit tweets.txt \ | |
--prefix='tweet.' --suffix-format='%03d.txt' \ | |
--elide-empty-files \ | |
--keep-files \ | |
2 '{*}' | |
# tag::A[] | |
diff -s tweets.txt <(cat tweet.*.txt) | |
# end::A[] | |
#= EXAMPLE-10A | |
csplit tweets.txt --keep-files 2 2 2 2 2 | |
#= EXAMPLE-10B | |
csplit tweets.txt --keep-files 2 4 6 8 10 | |
#= EXAMPLE-10C | |
csplit tweets.txt --keep-files 2 '{4}' | |
#= EXAMPLE-11 | |
tr [:lower:] [:upper:] < tweets.txt | csplit - \ | |
--prefix='tweet.' --suffix-format='%03d.txt' \ | |
--elide-empty-files \ | |
--keep-files \ | |
2 '{3}' | |
head tweet.???.txt | |
#= EXAMPLE-12C | |
# Keep only the third and fourth tweets | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
--keep-files \ | |
%----% '{2}' /----/ '{2}' %----% '{*}' | |
head tweet.00[012].yaml | |
#= EXAMPLE-12B | |
# Skip the first two tweets | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
--keep-files \ | |
%----% '{2}' /----/ '{2}' | |
head tweet.00[012].yaml | |
#= EXAMPLE-12A | |
# Keep only the first two tweets | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
--keep-files \ | |
/----/ '{2}' %----% '{*}' | |
head tweet.00[012].yaml | |
#= EXAMPLE-13A | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
--keep-files \ | |
%----%+1 '{2}' /----/+1 '{2}' %----% '{*}' | |
head tweet.00[012].yaml | |
#= EXAMPLE-13B | |
csplit tweets.yaml \ | |
--prefix='tweet.' --suffix-format='%03d.yaml' \ | |
--elide-empty-files \ | |
--keep-files \ | |
%----%+1 '{2}' /----/+1 '{2}' %----% '{*}' | |
head tweet.00[012].yaml | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
function flush() { | |
if (status) { | |
print "{" repeat "}" | |
print status | |
} | |
reset(); | |
} | |
function reset() { | |
instatus = 0; | |
repeat = ""; | |
status = ""; | |
} | |
BEGIN { | |
reset(); | |
} | |
/----/ { flush(); next } | |
/repeat:/ { repeat = " " $3 $4 " "; next } | |
/status:/ { instatus = 1; next } | |
instatus { | |
if (status) | |
status = status "\\n"; | |
text = $0 | |
gsub(/^[ \t]+/, "", text) | |
status = status text | |
} | |
END { flush() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
function send(text) { | |
if (!DIRTY) { | |
gsub(/^[ \t\n]+/,"", text); | |
} | |
gsub(/[ \t\n]$/,"", text); | |
if (text) { | |
COMMAND = "bash -i 2>&1"; | |
gsub(/[\n]+$/, "", POST); | |
if (!POST) | |
POST = "cat" | |
COMMAND = COMMAND " | " POST " > " OUTFILE; | |
print text | COMMAND; | |
DIRTY=1; | |
} | |
} | |
function setOutFile(file) { | |
if(DIRTY) close(COMMAND); | |
DIRTY=0; | |
OUTFILE = file; | |
} | |
BEGIN { | |
OUTFILE = "example" | |
STATES["INIT"] = ++_ID; | |
STATES["WORK"] = ++_ID; | |
STATES["POST"] = ++_ID; | |
} | |
/^#=/ { | |
STATE = STATES["WORK"]; | |
BUFFER = ""; | |
FILE = $1 $2; | |
gsub(/^#=[ \t]*/, "", FILE); | |
setOutFile(FILE); | |
send(INIT); | |
DIRTY = 0; | |
next; | |
} | |
/^#![ \t]*INIT/ { | |
STATE = STATES["INIT"]; | |
next | |
} | |
/^#![ \t]*POST/ { | |
STATE = STATES["POST"]; | |
next | |
} | |
STATE == STATES["INIT"] { | |
INIT = INIT $0 "\n" | |
} | |
STATE == STATES["POST"] { | |
POST = POST $0 "\n" | |
} | |
STATE == STATES["WORK"] { | |
BUFFER = BUFFER $0 "\n" | |
} | |
STATE == STATES["WORK"] && /[^ \t]/ { | |
send(BUFFER); | |
BUFFER = ""; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ days:180 } | |
Still hesitating between #Vim and #Emacs?\nWhy not take a look at #spacemacs?\n\nhttp://spacemacs.org/ | |
{} | |
Print the first column of a space-separated data file:\nawk '{print $1}' data.txt # Print out just the first column\n\nFor some unknown reason, I find that easier to remember than:\ncut -f1 data.txt\n\n#Linux #AWK #Cut | |
{} | |
For the #shell #beginners :\n« #GlobPatterns : how to move hundreds of files in not time [1/3] »\nhttps://youtu.be/TvW8DiEmTcQ\n\n#Unix #Linux\n#YesIKnowIT | |
{} | |
Want to know the oldest file in your disk?\n\nfind / -type f -printf '%TFT%.8TT %p\n' | sort | less\n(should work on any Single UNIX Specification compliant system)\n#UNIX #Linux | |
{} | |
When using the find command, use `-iname` instead of `-name` for case-insensitive search\n#Unix #Linux #Shell #Find | |
{} | |
From a POSIX shell `$OLDPWD` holds the name of the previous working directory:\ncd /tmp\necho You are here: $PWD\necho You were here: $OLDPWD\ncd $OLDPWD\n\n#Unix #Linux #Shell #cd | |
{} | |
From a POSIX shell, "cd" is a shorthand for cd $HOME\n#Unix #Linux #Shell #cd | |
{} | |
How to move hundreds of files in no time?\nUsing the find command!\n\nhttps://youtu.be/zmEFXjyzaQk\n#Unix #Linux #Move #Files #Find\n#YesIKnowIT | |
{} | |
If your shell supports history, use "!-1" to repeat the last command.\n"!!" is a shorthand for that too\n#Unix #Linux #Shell | |
{} | |
If your shell supports job control, type <CTRL-z> "bg" from its parent shell to send a process to the background\n#Shell #Bash #JobControl | |
{} | |
`ls -lt` will show files ordered by modification date — most recent first.\n\n#ls #shell #linux | |
{} | |
`ls -r` will reverse the normal order of the ls output. Try `ls -rlt` for example.\n\n#ls #shell #linux | |
{} | |
In the Bash, pressing "ctrl-x ctrl-v" will display its version informations.\n\n#bash #linux | |
{} | |
You know the "globstar" feature of your Bash ?\nLet's talk about that !\nhttps://youtu.be/N8zAA7GG56g\n\n#Linux #Bash #Globstar | |
{} | |
20 files to rename. 5 seconds per file. 1"40 of boring work?\nNo: 15 seconds if you know the right command\nhttps://yesik.it/EP04\n\n#Shell #Rename #PRename | |
{} | |
`less -R` will handle gracefully ANSI "color" escape sequences:\nls --color=always /tmp | less -R\n\n#Linux #Shell #ls | |
{} | |
`‥ | read ‥` is not portable between #zsh and #bash\n\nCompare in both shells :\necho 1 | read X; echo $X | |
{} | |
In Bash the pseudo-variable RANDOM returns a pseudo-random integer in the [0;32767] range\n\necho $RANDOM\n\n#Bash #Random | |
{} | |
With Bash history, `^str1^str2^` will repeat the previous command replacing `str1` by `str2`\n\necho 1223\n^2^4^\n\n#Bash | |
{ days:200 } | |
Nice introductory article on Awk by Justin Ellingwood (@jmellingwood):\nhttps://www.digitalocean.com/community/tutorials/how-to-use-the-awk-language-to-manipulate-text-in-linux | |
{} | |
If you don't know what is #Awk or how it could help you processing text files, then you NEED that little introduction:\nhttps://youtu.be/PUYS6MO4p7Y\n\n#Linux #Shell #AWK\n#YesIKnowIT | |
{} | |
In Bash `$(<file)` is equivalent to `$(cat file)`, but faster:\n\nP=( $(</etc/passwd) )\necho ${P[0]}\n\n#Bash #Linux #Cat | |
{} | |
The #Bash has the notion of "integer" variable:\n\ndeclare A=1; declare -i B=2\nA+=3; B+=4\necho $A $B\n⇒ 13 6\n\n#Shell | |
{} | |
In Bash,\n`~+` is expanded to the content of `PWD`\n`~-` is expanded to the content of `OLDPWD`\n\ncd /tmp\necho You are here: ~+\necho You were here: ~-\n\n#Bash #Shell | |
{ days:65 } | |
Do you know I have a "Bash and Linux Command Line" course On #Udemy?\nTake a look here for a discount:\nhttps://yesik.it/BSH101 | |
{} | |
In #Bash, to edit the last three commands in your favorite EDITOR type:\n\nfc -3 0\n\nWhen leaving the editor, commands are executed | |
{} | |
To leave #vim with a non-zero exit code use `:cq`.\n\nUseful to abort a #Git commit or a #Bash `fc` command | |
{} | |
So, you don't know yet the `grep` command ?\nhttps://youtu.be/HBNNO92Juw4\n\n#Shell #Linux #Grep\n#YesIKnowIT | |
{ days:180 } | |
Nice introduction to sed, the Stream EDitor :\n\nhttps://www.digitalocean.com/community/tutorials/the-basics-of-using-the-sed-stream-editor-to-manipulate-text-in-linux\nby @jmellingwood | |
{} | |
Not all you can do with sed, but a cool reminder for the most basic use cases:\nhttps://www.yesik.it/SEDCS1\n\n#sed #cheatsheet | |
{} | |
I think I use the `sed` command daily. And you?\n\nhttps://www.yesik.it/EP07\n#Shell #Linux #Sed\n#YesIKnowIT | |
{} | |
Delete the last line of a file:\nsed '$d' file\n\n#Shell #Sed #Linux | |
{} | |
Delete all but the last line of a file:\nsed -n '$p' file\n\n#Shell #Sed #Linux | |
{} | |
Display the first 5 lines of a file:\nsed '5q' file\n\n#Shell #Sed #Linux | |
{} | |
Hello,\nI'm Sylvain...\n... and I'm a Vim Addict.\n\nhttps://itsfoss.com/pro-vim-tips/ by @Yes_I_Know_IT\n#Vim #TextEditor #Linux\n#YesIKnowIT | |
{} | |
Centering text on 80 columns with stars:\nsed -E ':x\ns/^.{,80}$/*&/\ns/^.{,80}$/&*/\ntx\n' file\n\n#Shell #Sed #Linux | |
{} | |
Right-align text on 80 columns:\nsed -E ':a /.{80}/!{s/^/ /;ba}' file\n\n#Shell #Sed #Linux | |
{} | |
The sed substitution (s) command is by far the most useful. But did you know ALL these patterns:\nhttps://www.yesik.it/EP08\n\n#Linux #Sed\n#YesIKnowIT | |
{} | |
ddrescue is one of the best tools to recover damaged disk (HD or optical).\n/!\ Don't miss the "log" feature for multipass recovery!\nhttps://www.linux.com/learn/intro-to-linux/2017/3/gnu-ddrescue-best-damaged-drive-rescue\n\n#HD #DVD #Rescue #RIP #ddrescue #Linux | |
{} | |
In a #sed substitution pattern, you can use any character as a separator instead of /\nUseful for path or urls:\ns!/usr/local!/opt!\n\n#Linux #UNIX | |
{} | |
Put emphasis around the Beattles\nsed -E 's!(John|Paul|George|Ringo)!<em>&</em>!g' file\n\n#Sed #Linux\nfrom https://www.yesik.it/EP08 | |
{} | |
Looking for an explanation of what is the kernel and how it relates to userspace applications?\nTake a look at that video:\nhttps://yesik.it/EP09\n\n#Kernel #Linux\n#YesIKnowIT | |
{} | |
GNU sed has a nice 'e' modifier for substitutions:\nsed 's/.*/date +%F -d &/e' << EOT\nnow\ntomorrow\nyesterday\nEOT\n\n#GNU #sed #Linux | |
{ days:180 } | |
Bash scripting 101:\nhttps://jvns.ca/blog/2017/03/26/bash-quirks/\nby @b0rk | |
{} | |
I investigate Diaspora* as an alternate social network.\nAnyone there?\nhttps://diasp.eu/public/YesIKnowIT\n#Diaspora @joindiaspora\n#YesIKnowIT | |
{ days:180 } | |
#Vim is great.\nI like #tmux more and more.\n\nHow could it be to use them both at the same time?\nhttps://blog.bugsnag.com/tmux-and-vim/\nby @keeganlow | |
{} | |
A #Mastodon instance for #Linux Lovers\nhttps://linuxrocks.online/about\n\nTry that new #SocialNetwork and follow me there https://yesik.it/mastodon\n#YesIKnowIT | |
{} | |
"I want to learn Linux. Is Kali right for me?"\nYes? No? Is that so simple?\n\nhttps://itsfoss.com/kali-linux-review/\n\n#Linux #Kali @itsfoss2\n#YesIKnowIT | |
{} | |
Glob patterns, from the basics to subtle corner cases:\nhttps://www.yesik.it/EP11\n\n#Linux #Shell #Bash #GlobPattern\n#YesIKnowIT | |
{ days:180 } | |
Very great description of the difference between VMs and Containers\nby @mikegcoleman\nhttps://blog.docker.com/2016/03/containers-are-not-vms/\n\n#Docker #Containers | |
{} | |
What is #Virtualization?\nAnd how does that relate to #Emulation, #Containers and #CloudComputing?\n\nhttps://www.yesik.it/EP12\n#YesIKnowIT | |
{ days:180 } | |
Different does not mean better or worst. It just means different.\n\nhttps://www.linux.com/learn/intro-to-linux/2017/6/what-nosql\nby @CarlaSchroder\n\n#SQL #NoSQL | |
{} | |
#VM #Containers #Emulation #Wine?\nWhich virtualization technology is the best for YOUR needs?\n\nhttps://yesik.it/VIRT101\n\n#CheatSheet\n#YesIKnowIT | |
{} | |
Print odd lines\nseq 10 | sed -n 'P;N'\n\n#Shell #Sed #Linux | |
{} | |
Print even lines\nseq 10 | sed -n '1b;P;N'\n\n#Shell #Sed #Linux | |
{} | |
My #Bash book available both as #PaperBook and #eBook\n\nhttps://yesik.it/BASH-IT-OUT/PAPER\nhttps://yesik.it/BASH-IT-OUT/PDF\nhttps://yesik.it/BASH-IT-OUT\n@itsfoss2\n#Linux #Shell #Puzzle #Book\n#YesIKnowIT | |
{ days:180 } | |
split and csplit -- old friends, I used a lot in the 1.44MB floppy disk era...\n\nhttps://www.linux.com/learn/intro-to-linux/2017/8/splitting-and-re-assembling-files-linux\nby @CarlaSchroder\n\n#Linux #Unix #Split #csplit | |
{} | |
In AWK an action without associated pattern defaults to 1.\nSo those two commands are the same:\n\nseq 10 | awk '{print}'\nseq 10 | awk '1 {print}'\n\n#Shell #AWK | |
{} | |
In AWK a pattern without associated action defaults to '{ print }':\nSo those two commands are the same:\n\nseq 10 | awk /1/ is the same as\nseq 10 | awk '/1/ {print}'\n\n#Shell #AWK | |
{} | |
Three completly different AWK programs:\n\nseq 10 | awk '1 { print }'\nseq 10 | awk '/1/ { print }'\nseq 10 | awk 'NR==1 { print }'\n\n#Shell #AWK #regex | |
{} | |
#OpenStack is a complex and somewhat frightening beast\nhttps://opensource.com/resources/what-is-openstack | |
{} | |
If you ever had to connect to an Oracle backend, you may know how painful it used to be to set up an Oracle Instance on your test/dev host.\n\nThanks to @Docker, it is now several orders of magnitude simpler!\n\nhttps://yesik.it/EP18\n\n#Oracle #Database\n#Docker #Container\n#Linux | |
{} | |
Fine tune Linux Kernel I/O by setting up dirty page parameters.\n\nhttps://lonesysadmin.net/2013/12/22/better-linux-disk-caching-performance-vm-dirty_ratio/\n\n#Linux #Kernel #Cache #Disk #Tuning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- | |
event: | |
repeat: { days: 180 } | |
status: | | |
Still hesitating between #Vim and #Emacs? | |
Why not take a look at #spacemacs? | |
http://spacemacs.org/ | |
---- | |
status: | | |
Print the first column of a space-separated data file: | |
awk '{print $1}' data.txt # Print out just the first column | |
For some unknown reason, I find that easier to remember than: | |
cut -f1 data.txt | |
#Linux #AWK #Cut | |
---- | |
status: | | |
For the #shell #beginners : | |
« #GlobPatterns : how to move hundreds of files in not time [1/3] » | |
https://youtu.be/TvW8DiEmTcQ | |
#Unix #Linux | |
#YesIKnowIT | |
---- | |
status: | | |
Want to know the oldest file in your disk? | |
find / -type f -printf '%TFT%.8TT %p\n' | sort | less | |
(should work on any Single UNIX Specification compliant system) | |
#UNIX #Linux | |
---- | |
status: | | |
When using the find command, use `-iname` instead of `-name` for case-insensitive search | |
#Unix #Linux #Shell #Find | |
---- | |
status: | | |
From a POSIX shell `$OLDPWD` holds the name of the previous working directory: | |
cd /tmp | |
echo You are here: $PWD | |
echo You were here: $OLDPWD | |
cd $OLDPWD | |
#Unix #Linux #Shell #cd | |
---- | |
status: | | |
From a POSIX shell, "cd" is a shorthand for cd $HOME | |
#Unix #Linux #Shell #cd | |
---- | |
status: | | |
How to move hundreds of files in no time? | |
Using the find command! | |
https://youtu.be/zmEFXjyzaQk | |
#Unix #Linux #Move #Files #Find | |
#YesIKnowIT | |
---- | |
status: | | |
If your shell supports history, use "!-1" to repeat the last command. | |
"!!" is a shorthand for that too | |
#Unix #Linux #Shell | |
---- | |
status: | | |
If your shell supports job control, type <CTRL-z> "bg" from its parent shell to send a process to the background | |
#Shell #Bash #JobControl | |
---- | |
status: | | |
`ls -lt` will show files ordered by modification date — most recent first. | |
#ls #shell #linux | |
---- | |
status: | | |
`ls -r` will reverse the normal order of the ls output. Try `ls -rlt` for example. | |
#ls #shell #linux | |
---- | |
status: | | |
In the Bash, pressing "ctrl-x ctrl-v" will display its version informations. | |
#bash #linux | |
---- | |
status: | | |
You know the "globstar" feature of your Bash ? | |
Let's talk about that ! | |
https://youtu.be/N8zAA7GG56g | |
#Linux #Bash #Globstar | |
---- | |
status: | | |
20 files to rename. 5 seconds per file. 1"40 of boring work? | |
No: 15 seconds if you know the right command | |
https://yesik.it/EP04 | |
#Shell #Rename #PRename | |
---- | |
status: | | |
`less -R` will handle gracefully ANSI "color" escape sequences: | |
ls --color=always /tmp | less -R | |
#Linux #Shell #ls | |
---- | |
status: | | |
`‥ | read ‥` is not portable between #zsh and #bash | |
Compare in both shells : | |
echo 1 | read X; echo $X | |
---- | |
status: | | |
In Bash the pseudo-variable RANDOM returns a pseudo-random integer in the [0;32767] range | |
echo $RANDOM | |
#Bash #Random | |
---- | |
status: | | |
With Bash history, `^str1^str2^` will repeat the previous command replacing `str1` by `str2` | |
echo 1223 | |
^2^4^ | |
#Bash | |
---- | |
event: | |
repeat: { days: 200 } | |
status: | | |
Nice introductory article on Awk by Justin Ellingwood (@jmellingwood): | |
https://www.digitalocean.com/community/tutorials/how-to-use-the-awk-language-to-manipulate-text-in-linux | |
---- | |
status: | | |
If you don't know what is #Awk or how it could help you processing text files, then you NEED that little introduction: | |
https://youtu.be/PUYS6MO4p7Y | |
#Linux #Shell #AWK | |
#YesIKnowIT | |
---- | |
status: | | |
In Bash `$(<file)` is equivalent to `$(cat file)`, but faster: | |
P=( $(</etc/passwd) ) | |
echo ${P[0]} | |
#Bash #Linux #Cat | |
---- | |
status: | | |
The #Bash has the notion of "integer" variable: | |
declare A=1; declare -i B=2 | |
A+=3; B+=4 | |
echo $A $B | |
⇒ 13 6 | |
#Shell | |
---- | |
status: | | |
In Bash, | |
`~+` is expanded to the content of `PWD` | |
`~-` is expanded to the content of `OLDPWD` | |
cd /tmp | |
echo You are here: ~+ | |
echo You were here: ~- | |
#Bash #Shell | |
---- | |
event: | |
repeat: { days: 65 } | |
status: | | |
Do you know I have a "Bash and Linux Command Line" course On #Udemy? | |
Take a look here for a discount: | |
https://yesik.it/BSH101 | |
---- | |
status: | | |
In #Bash, to edit the last three commands in your favorite EDITOR type: | |
fc -3 0 | |
When leaving the editor, commands are executed | |
---- | |
status: | | |
To leave #vim with a non-zero exit code use `:cq`. | |
Useful to abort a #Git commit or a #Bash `fc` command | |
---- | |
status: | | |
So, you don't know yet the `grep` command ? | |
https://youtu.be/HBNNO92Juw4 | |
#Shell #Linux #Grep | |
#YesIKnowIT | |
---- | |
event: | |
repeat: { days: 180 } | |
status: | | |
Nice introduction to sed, the Stream EDitor : | |
https://www.digitalocean.com/community/tutorials/the-basics-of-using-the-sed-stream-editor-to-manipulate-text-in-linux | |
by @jmellingwood | |
---- | |
status: | | |
Not all you can do with sed, but a cool reminder for the most basic use cases: | |
https://www.yesik.it/SEDCS1 | |
#sed #cheatsheet | |
---- | |
status: | | |
I think I use the `sed` command daily. And you? | |
https://www.yesik.it/EP07 | |
#Shell #Linux #Sed | |
#YesIKnowIT | |
---- | |
status: | | |
Delete the last line of a file: | |
sed '$d' file | |
#Shell #Sed #Linux | |
---- | |
status: | | |
Delete all but the last line of a file: | |
sed -n '$p' file | |
#Shell #Sed #Linux | |
---- | |
status: | | |
Display the first 5 lines of a file: | |
sed '5q' file | |
#Shell #Sed #Linux | |
---- | |
status: | | |
Hello, | |
I'm Sylvain... | |
... and I'm a Vim Addict. | |
https://itsfoss.com/pro-vim-tips/ by @Yes_I_Know_IT | |
#Vim #TextEditor #Linux | |
#YesIKnowIT | |
---- | |
status: | | |
Centering text on 80 columns with stars: | |
sed -E ':x | |
s/^.{,80}$/*&/ | |
s/^.{,80}$/&*/ | |
tx | |
' file | |
#Shell #Sed #Linux | |
---- | |
status: | | |
Right-align text on 80 columns: | |
sed -E ':a /.{80}/!{s/^/ /;ba}' file | |
#Shell #Sed #Linux | |
---- | |
status: | | |
The sed substitution (s) command is by far the most useful. But did you know ALL these patterns: | |
https://www.yesik.it/EP08 | |
#Linux #Sed | |
#YesIKnowIT | |
---- | |
status: | | |
ddrescue is one of the best tools to recover damaged disk (HD or optical). | |
/!\ Don't miss the "log" feature for multipass recovery! | |
https://www.linux.com/learn/intro-to-linux/2017/3/gnu-ddrescue-best-damaged-drive-rescue | |
#HD #DVD #Rescue #RIP #ddrescue #Linux | |
---- | |
status: | | |
In a #sed substitution pattern, you can use any character as a separator instead of / | |
Useful for path or urls: | |
s!/usr/local!/opt! | |
#Linux #UNIX | |
---- | |
status: | | |
Put emphasis around the Beattles | |
sed -E 's!(John|Paul|George|Ringo)!<em>&</em>!g' file | |
#Sed #Linux | |
from https://www.yesik.it/EP08 | |
---- | |
status: | | |
Looking for an explanation of what is the kernel and how it relates to userspace applications? | |
Take a look at that video: | |
https://yesik.it/EP09 | |
#Kernel #Linux | |
#YesIKnowIT | |
---- | |
status: | | |
GNU sed has a nice 'e' modifier for substitutions: | |
sed 's/.*/date +%F -d &/e' << EOT | |
now | |
tomorrow | |
yesterday | |
EOT | |
#GNU #sed #Linux | |
---- | |
event: | |
repeat: { days: 180 } | |
status: | | |
Bash scripting 101: | |
https://jvns.ca/blog/2017/03/26/bash-quirks/ | |
by @b0rk | |
---- | |
status: | | |
I investigate Diaspora* as an alternate social network. | |
Anyone there? | |
https://diasp.eu/public/YesIKnowIT | |
#Diaspora @joindiaspora | |
#YesIKnowIT | |
---- | |
event: | |
repeat: { days: 180 } | |
status: | | |
#Vim is great. | |
I like #tmux more and more. | |
How could it be to use them both at the same time? | |
https://blog.bugsnag.com/tmux-and-vim/ | |
by @keeganlow | |
---- | |
status: | | |
A #Mastodon instance for #Linux Lovers | |
https://linuxrocks.online/about | |
Try that new #SocialNetwork and follow me there https://yesik.it/mastodon | |
#YesIKnowIT | |
---- | |
status: | | |
"I want to learn Linux. Is Kali right for me?" | |
Yes? No? Is that so simple? | |
https://itsfoss.com/kali-linux-review/ | |
#Linux #Kali @itsfoss2 | |
#YesIKnowIT | |
---- | |
status: | | |
Glob patterns, from the basics to subtle corner cases: | |
https://www.yesik.it/EP11 | |
#Linux #Shell #Bash #GlobPattern | |
#YesIKnowIT | |
---- | |
event: | |
repeat: { days: 180 } | |
status: | | |
Very great description of the difference between VMs and Containers | |
by @mikegcoleman | |
https://blog.docker.com/2016/03/containers-are-not-vms/ | |
#Docker #Containers | |
---- | |
status: | | |
What is #Virtualization? | |
And how does that relate to #Emulation, #Containers and #CloudComputing? | |
https://www.yesik.it/EP12 | |
#YesIKnowIT | |
---- | |
event: | |
repeat: { days: 180 } | |
status: | | |
Different does not mean better or worst. It just means different. | |
https://www.linux.com/learn/intro-to-linux/2017/6/what-nosql | |
by @CarlaSchroder | |
#SQL #NoSQL | |
---- | |
status: | | |
#VM #Containers #Emulation #Wine? | |
Which virtualization technology is the best for YOUR needs? | |
https://yesik.it/VIRT101 | |
#CheatSheet | |
#YesIKnowIT | |
---- | |
status: | | |
Print odd lines | |
seq 10 | sed -n 'P;N' | |
#Shell #Sed #Linux | |
---- | |
status: | | |
Print even lines | |
seq 10 | sed -n '1b;P;N' | |
#Shell #Sed #Linux | |
---- | |
status: | | |
My #Bash book available both as #PaperBook and #eBook | |
https://yesik.it/BASH-IT-OUT/PAPER | |
https://yesik.it/BASH-IT-OUT/PDF | |
https://yesik.it/BASH-IT-OUT | |
@itsfoss2 | |
#Linux #Shell #Puzzle #Book | |
#YesIKnowIT | |
---- | |
event: | |
repeat: { days: 180 } | |
status: | | |
split and csplit -- old friends, I used a lot in the 1.44MB floppy disk era... | |
https://www.linux.com/learn/intro-to-linux/2017/8/splitting-and-re-assembling-files-linux | |
by @CarlaSchroder | |
#Linux #Unix #Split #csplit | |
---- | |
status: | | |
In AWK an action without associated pattern defaults to 1. | |
So those two commands are the same: | |
seq 10 | awk '{print}' | |
seq 10 | awk '1 {print}' | |
#Shell #AWK | |
---- | |
status: | | |
In AWK a pattern without associated action defaults to '{ print }': | |
So those two commands are the same: | |
seq 10 | awk /1/ is the same as | |
seq 10 | awk '/1/ {print}' | |
#Shell #AWK | |
---- | |
status: | | |
Three completly different AWK programs: | |
seq 10 | awk '1 { print }' | |
seq 10 | awk '/1/ { print }' | |
seq 10 | awk 'NR==1 { print }' | |
#Shell #AWK #regex | |
---- | |
status: | | |
#OpenStack is a complex and somewhat frightening beast | |
https://opensource.com/resources/what-is-openstack | |
---- | |
status: | | |
If you ever had to connect to an Oracle backend, you may know how painful it used to be to set up an Oracle Instance on your test/dev host. | |
Thanks to @Docker, it is now several orders of magnitude simpler! | |
https://yesik.it/EP18 | |
#Oracle #Database | |
#Docker #Container | |
#Linux | |
---- | |
status: | | |
Fine tune Linux Kernel I/O by setting up dirty page parameters. | |
https://lonesysadmin.net/2013/12/22/better-linux-disk-caching-performance-vm-dirty_ratio/ | |
#Linux #Kernel #Cache #Disk #Tuning |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment