Git Product home page Git Product logo

onceupon / bash-oneliner Goto Github PK

View Code? Open in Web Editor NEW
8.1K 8.1K 547.0 992 KB

A collection of handy Bash One-Liners and terminal tricks for data processing and Linux system maintenance.

Home Page: http://onceupon.github.io/Bash-Oneliner/

License: MIT License

bash data-processing grep hardware linux linux-administration one-liners oneliner-commands shell shell-oneliner system terminal variables xargs xwindow

bash-oneliner's People

Contributors

0xflotus avatar 5c077m4n avatar acmello avatar chapeupreto avatar chapmanjacobd avatar dimisjim avatar fazlearefin avatar hanemile avatar herrcykel avatar ivothgle avatar jacksonbailey avatar jibanyan3456 avatar linus avatar matthewhelmke avatar nateeag avatar onceupon avatar poplaryang avatar sarlej avatar siansiansu avatar simeg avatar strahinja avatar valerionew avatar wardmaes avatar will-b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bash-oneliner's Issues

typo in terminal tricks

Hi,

First thing I just want to congratulate you on this great list. I was looking for something like this for a while and I'm glad to see that you did a fantastic job compiling this list.
Now I just want to let you know about a typo I've noticed Terminal Tricks / Change case: https://github.com/onceupon/Bash-Oneliner#change-case
Esc + l changes the text to lowercase not uppercase.

Remove ‘ ’ style quotes from README.ME.

Remove the ‘ ’ style quotes and replace with ASCII single quotes.

README.md:106:3:# ‘[]’ serves to match the character from a range.
README.md:106:8:# ‘[]’ serves to match the character from a range.
README.md:109:3:# ‘{}’ can be used to match filenames with more than one patterns
README.md:109:8:# ‘{}’ can be used to match filenames with more than one patterns
README.md:287:6:grep ‘[0-9]\{3\}’
README.md:287:19:grep ‘[0-9]\{3\}’
README.md:289:9:grep -E ‘[0-9]{3}’
README.md:289:20:grep -E ‘[0-9]{3}’
README.md:291:9:grep -P ‘\d{3}’
README.md:291:17:grep -P ‘\d{3}’
README.md:405:6:grep ‘colou?r’
README.md:405:16:grep ‘colou?r’
printf '‘’' | od -a
0000000   b nul can   b nul  em
0000006

factor 50

factor is not a bash built-in nor a bash plugin. It's a program in its own right, independent of bash, part of gnu coreutils, and is related to bash about as much as, say, a video- or music player is.

busybox provides a factor app too, alas it's much more limited in allowable number range than the coreutils version, which I tend to use as quick poor person's CPU benchmark:

time factor 1234567890123456789012345678901

As this yields two large prime factors, it takes a reasonable (as in measurable) time. Because the number is easy to memorize, and can be shortcut nicely with copy-and-paste, it serves as a nice rough evaluation of CPU performance - depending on machine between about 150ms for notebooks and desktop computers, to 400 to 1000 and above ms for ARM SBC. My WiFi router takes about 4 seconds, comparable to oldish ARM SBCs.

Nevertheless, factor still isn't related to bash.

Doubled single quotes does NOT act as double quotes

Error in the README "Variable substitution within quotes" section.

# doubled single quotes act as double quotes making variables expand
echo ''$foo''
# bar

Technically it doesn't act as double quotes, but acts as if there were no quotes at all.
The difference lies on word splitting.
An example with mkdir can show the difference:

foo='a b'
mkdir $foo # Expected result: two directories, 'a' 'b'
mkdir ''$foo'' # Expected result: two directories, 'a' 'b'
mkdir "$foo" # Expected result: one directory, 'a b'

In "data wrangling", one correction and a new suggestion

First off, at the beginning of the "data wrangling" section, in the example output for the look command, you say that you are running the command look phy|head -n 10 but the output does not show words beginning with phy. It instead shows word beginning with Phi. I would change this section to:

##### Print some words that start with a particular string (e.g. words start with 'phy')
```bash
# If file is not specified, the file /usr/share/dict/words is used.
look phy|head -n 10
# Phyciodes
# phycite
# Phycitidae
# phycitol
# phycochromaceae
# phycochromaceous
# phycochrome
# Phycochromophyceae
# phycochromophyceous
# phycocyanin
```

Secondly, I would add some usage of the command comm to find between two sorted files common lines, lines in one file but not in another; something like:

##### Find common/differing lines
The command `comm` can be used to find lines common to two files (intersection), or to find lines in one file and not in another file. **Warning**: input files must be sorted.
```bash
# Sort input before handing to comm; the -o option lets you sort a file in-place
sort -o bad-actors.txt bad-actors.txt
sort -o invited-guests.txt invited-guests.txt
# Find lines in both files
comm -12 bad-actors.txt invited-guests.txt
# Find lines in invited-guests.txt that are NOT in bad-actors.txt
comm -13 bad-actors.txt invited-guests.txt
# Find lines that are in good-actors.txt but NOT in invited-guests.txt.
# Note that since we didn't sort good-actors.txt above, we need to sort it before handing it to comm
comm -23 <(sort good-actors.txt) invited-guests.txt
```

This can also be combined with use of jq to do things like "compare these two json arrays of strings, and find the strings that are in both arrays".

Bash-Oneliner as an Jupyter Notebook tree

Nice collection of examples! Thank you for your work!

Did you consider the conversion of Bash-Oneliner to Jupyter Notebook tree as an option?
This can provide more interactivity and structuralism for examples

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.