/dev/random and /dev/urandom can be used as the random number generator --random-source=FILE
chown, chgrp, and chmod all accept -R or the recursive option, which means do this command for all directories underneath what this command specifies
ls ~/Documents/
chown joshua ~/documents/
#+BEGIN_SRC sh :dir ~/programming/waypoint/nutripledge/ find . -name '.*php' -print #+END_SRC
#+RESULTS: | ./calendar1/__MACOSX/supercali-1.0.8/._modules.php | | ./calendar1/__MACOSX/supercali-1.0.8/modules/._week.php | | ./calendar1/__MACOSX/supercali-1.0.8/modules/._year.php | | ./calendar1/__MACOSX/supercali-1.0.8/modules/._upcoming.php | | ./calendar1/__MACOSX/supercali-1.0.8/modules/._grid.php | | ./calendar1/__MACOSX/supercali-1.0.8/modules/._weeklist.php | | ./calendar1/__MACOSX/supercali-1.0.8/modules/._day_week_functions.php | | ./calendar1/__MACOSX/supercali-1.0.8/modules/._quarter.php | | ./calendar1/__MACOSX/supercali-1.0.8/modules/._day.php | | ./calendar1/__MACOSX/supercali-1.0.8/._edit_users.php | | ./calendar1/__MACOSX/supercali-1.0.8/._delete_event.php | | ./calendar1/__MACOSX/supercali-1.0.8/._admin_actions.php | | ./calendar1/__MACOSX/supercali-1.0.8/._edit_links.php | | ./calendar1/__MACOSX/supercali-1.0.8/._bad_password.php | | ./calendar1/__MACOSX/supercali-1.0.8/._login.php | | ./calendar1/__MACOSX/supercali-1.0.8/includes/._notify.php | | ./calendar1/__MACOSX/supercali-1.0.8/includes/._session_start.php | | ./calendar1/__MACOSX/supercali-1.0.8/includes/._nav.php | | ./calendar1/__MACOSX/supercali-1.0.8/includes/._start.php | | ./calendar1/__MACOSX/supercali-1.0.8/includes/._footer.php | | ./calendar1/__MACOSX/supercali-1.0.8/includes/._top_nav.php | | ./calendar1/__MACOSX/supercali-1.0.8/includes/._hidden_fields.php | | ./calendar1/__MACOSX/supercali-1.0.8/._edit_categories.php | | ./calendar1/__MACOSX/supercali-1.0.8/._upload_events.php | | ./calendar1/__MACOSX/supercali-1.0.8/._edit_groups.php | | ./calendar1/__MACOSX/supercali-1.0.8/._edit_event.php | | ./calendar1/__MACOSX/supercali-1.0.8/._user_profile.php | | ./calendar1/__MACOSX/supercali-1.0.8/lang/._en_us.php |
#+BEGIN_SRC sh :dir ~/programming/waypoint/henriott-group/ find . -name \*.php -print #+END_SRC
#+RESULTS: | ./.#b3.php | | ./history.php | | ./staff.php | | ./p7.php | | ./about.php | | ./p5.php | | ./talk.php | | ./b3.php | | ./industries.php | | ./account.php | | ./industry-pictures.php | | ./2.php | | ./css/connect-to-database.php | | ./contact.php | | ./b4.php | | ./includes/footer.php | | ./includes/nav.php | | ./includes/header.php | | ./products.php |
To find all of the selected files (including sub-directories) and then delete them
#+BEGIN_SRC sh :dir ~/programming/waypoint/nutripledge/ find . -name \*.pdf -exec /bin/rm {} \; #+END_SRC
#+RESULTS:
find . -name '*png' -o -name '*svg' -o -name '*jpg'
./donate/foss_factory/logo.png |
./hurd/status/hurd-fvwm-screenshot-2009-11-12.png |
./hurd/status/hurd-iceweasel-screenshot-2012-03-21.png |
./logo/boxes-redrawn.png |
./logo/boxes-redrawn.svg |
./microkernel/OS-structure.svg |
./open_issues/c42ea6c9-f574-4b33-8440-f846b05856de.png |
./unsorted/FunnyHurd/HurdCarDeal.jpg |
./unsorted/FunnyHurd/HurdMagician.jpg |
./unsorted/GrantBowHurdPage/diagram.png |
./unsorted/JoachimNilssonHurdPage/patch_kit.jpg |
./unsorted/SeenHurd/lmf10_1999.jpg |
./unsorted/TestWebMenu/lmf09_1999.jpg |
./unsorted/WebHome/hurd_sm_mf.png |
./user/jkoenig/gsoc2011_classes.png |
grep searching a list of file/s for a pattern and outputs the matching lines. Grep only supports a handful of regular expressions. If you want to use ALL of the regexp expression goodies, you need to use egrep. fgrep is fast grep. It interprets the string as a literal string and not a regexp.
There is no way to match newline characters with grep. info:grep#Introduction #+BEGIN_SRC grep OPTIONS PATTERN [INPUT_FILE_NAMES | - ] #+END_SRC
The "-" for grep means standard input.
ie:
#+BEGIN_SRC sh :dir ~/ grep -rc th | grep -m 5 Sass - #+END_SRC
#+RESULTS: | .gem/ruby/2.3.0/doc/sass-3.4.21/ri/Sass/Tree/MediaNode/value-i.ri:1 | | .gem/ruby/2.3.0/doc/sass-3.4.21/ri/Sass/Tree/MediaNode/resolved_value-i.ri:1 | | .gem/ruby/2.3.0/doc/sass-3.4.21/ri/Sass/Tree/MediaNode/new-c.ri:1 | | .gem/ruby/2.3.0/doc/sass-3.4.21/ri/Sass/Tree/MediaNode/name-i.ri:1 | | .gem/ruby/2.3.0/doc/sass-3.4.21/ri/Sass/Tree/MediaNode/query-i.ri:1 |
If you want to search for a regexp in the current directory and all sub-directories
#+BEGIN_SRC grep -lr "" #+END_SRC
command options
lets you specify a pattern by regexp, and you can specify multiple patters!
grep -e be -e lint unofficial-packages.txt
bemenu-git r223.c3abc43-1 csslint 0.10.0-1
So I can see "be"menu and css"lint", but you could do the same thing with
egrep "be|lint" unofficial-packages.txt
bemenu-git r223.c3abc43-1 csslint 0.10.0-1
Note that the e flag should be given last on the flag list. If it is given first, then the rest of your flags will be thought of as the argument. ie:
grep -ei -
-R searches recursively following all symlinks exclude any dirs that match the GLOB The GLOB can use "?,*[...]" to match. I don't believe that you can use a regexp expression though exclude any files that match the pattern. The GLOB can use "?,*[...]" to match. I don't believe that you can use a regexp expression though include any files that match the pattern. The GLOB can use "?,*[...]" to match. I don't believe that you can use a regexp expression though
This lets you say that you want to ignore case in your grep search
grep -i soups cooking.org
* Soups ** Do not push cut garlic into soups. EVER.
You can see that it changed my pattern into [Ss]oups
grep -i soup cooking.org
* Soups ** Do not push cut garlic into soups. EVER. You will ruin the soup. It will be way too garlicky!
Suppose that we do not only the word "soup" and not to match "soups." or "Soups". We could do this:
grep -i "\bsoup\b" cooking.org
You will ruin the soup. It will be way too garlicky!
or to save some time, we could do this:
grep -iw soup cooking.org
You will ruin the soup. It will be way too garlicky!
This just says that the regexp should match the whole line. So it's like saying "^" PATTERN "$" output the total count the matching lines in the file
grep -c the hurd.org
2
grep -c the pacman.org practical-gnus.org
pacman.org:4 practical-gnus.org:65
grep -nm 6 -e the pacman.org practical-gnus.org
pacman.org:15:*** Failed to commit transaction package: path/to/file exists in the filesystem pacman.org:21: The problem is usually trivial to solve. A safe way is to first check if another package owns the file (pacman -Qo /path/to/file). If the file is owned by another package, file a bug report. If the file is not owned by another package, rename the file which 'exists in filesystem' and re-issue the update command. If all goes well, the file may then be removed. pacman.org:25: Every installed package provides a /var/lib/pacman/local/$package-$version/files file that contains metadata about this package. If this file gets corrupted, is empty or goes missing, it results in file exists in filesystem errors when trying to update the package. Such an error usually concerns only one package. Instead of manually renaming and later removing all the files that belong to the package in question, you may exceptionally run pacman -S --force $package to force pacman to overwrite these files. pacman.org:30:1 The Official name is Arch Linux, but I prefer to call it Arch GNU/Linux, to respect the hard word that GNU put into creating the GNU/Linux operating system. For more information, you can check out: What's in a Name? and GNU/Linux FAQ. practical-gnus.org:18:Copyright: This work is licensed under the [[http://creativecommons.org/licenses/by-nc-nd/3.0][Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License]]. practical-gnus.org:23:People think it is hard because they get lost in its features. It would be much easier if they learned the essential 5% features and ignore the remaining 95%. practical-gnus.org:32:- Usable when offline. Check the "offline" part in the section "Advanced tips" practical-gnus.org:33:- powerful combined with other plugins like yasnippet practical-gnus.org:37:- "C" means "Ctrl" and "M" means "Alt". For example, "M-x" means pressing "Alt" and "X" together. practical-gnus.org:41:- "Group buffer" means the list of folders.
print NUMber of lines after the match
print NUM of lines before the match
print NUM of lines before and after.
egrep is extended regexp
In Unix everything is a file. When you write a text document called "text.text", that is a Unix file. When you create a directory (Windows users call this a folder) called "Music", you also are creating a Unix file. Obviously, "text.text" and "Music" behave very differently. One has your favorite songs, and the other is a text document, BUT the linux kernel assumes that they are both Unix files. All unix files have read, write, and execute permissions specific to each unix file. This typiccally means that the ordinary user joshua cannot read, write, or execute anything in the /root/
folder.
read = 4
write = 2
execute = 1
owner = read | write = 6
group = read = 4
other = read = 4
The basic syntax of the command to set the mode is
chmod 644 [file name]
In C, that would be
#include <sys/stat.h>
chmod("[file name]", 0644);
#+END_SRC
#+RESULTS:
#+BEGIN_LaTeX
read = 4
write = 2
execute = 1
owner = read | write = 6
group = read = 4
other = read = 4
The basic syntax of the command to set the mode is
chmod 644 [file name]
In C, that would be
#include <sys/stat.h>
chmod("[file name]", 0644);
chmod [-R ] [file | directory]
Change a file's modifications. This specifies if what user, group, and if everyone else can read, write, or execute the file.
Permissions can modify the permissions of the user's, the group's and all others.
chown [-R] [file | directory]
Change the file's owner. The file's owner is typically root or an ordinary user.
Examples include
chgrp [ -R ] [file | directory]
Change the group that the file or directory belongs to.
#+BEGIN_SRC sh find . -name "pattern" -print
find . -name "this-file.*" -print
find . -name "this-file.*txt" -print
find . -name "this-file\.txt" -print #+END_SRC Access Modify Change
join [OPTIONS] [FILE1 | - ] [ FILE2 | - ]
A way of combining two files based on a common column.
Either file1 or file2 can be "-", which is standard input. So that is pretty cool.
print a line for each unpairable line.
Join on the nth column. For example is the following line =this is an example line=
"an" is on the 3rd field.
Join on the nth column. For example is the following line =this is an example line=
"example" is on the 4th field.
join -1 1 file1.txt file2.txt
1 12 18 this is 2 11 17 an interesting 3 10 16 experiment isn't 4 9 15 it? 5 e e 2nd field match 6 7 13 7 6 12 8 5 11 9 f f 2nd field match 10 3 9 11 2 8 12 1 7
join -1 2 file1.txt file2.txt
lets you get stdin and feed it to other programs that otherwise would not like it, allegedly
ls *org | xargs -i echo the{}et
theaccrisoft.orget theapache.orget thearch.orget theauto-complete.orget thebash.orget thebbdb.orget thecore-utils.orget thedired.orget thedisk.de.orget theelisp.orget theemacs.orget theevil-dvorak.orget theevil.orget thefirefox.orget thegawk.orget thegimp.orget thegit.orget thegnuplot.orget thegnus.orget thegpg.orget thehurd.orget thehurd-rpc.orget thehurd-talk.orget theinetutils.orget theiptables.orget thejavascript.orget thejson.orget theledger.orget thelinux-kernel-coding-style.orget themach-paging-interface.orget themagit.orget themaking-money-with-free-software.orget theman.orget themysql.orget thenetworks-networking-internet-ip4-tcp-udp.orget theorg-babel-code-block-args.orget theorg-babel-intro.orget theorg-babel-sql.orget theorg.orget thepacman.orget thephp.orget thepixi.orget thepractical-gnus.orget thesed.orget thesql.orget thesystemd.orget thethundertalks.orget thetoward-a-new-strategy-of-os-design.orget thetranslator-primer.orget thetranslators.orget thewhm.orget thewordpress.orget
ls *org | xargs -n 3
4yearsOfLife.org 4yearsOfLife.org.org a-certain-matchbox-member.org a-girl-hitting-a-man-is-hypocritical.org approaching-and-meeting-people.org cooking.org cover-letter.org example-latex.org gnu-assign-copyright-hurd-email-assign.org how-to-succeed-in-the-army.org intro-to-gnu-linux.org letter-to-dad.org letterToNicole.org letter-to-vincent.org libre-software-response.org professor-snape-rachel-sweet-bread.org references.org romance-story.org soihub-pages.org university-place.org why-proprietary-software-is-wrong.org
sort [OPTION] [FILE] This is good for sorting
50M -10G 1.5K use SEPARATOR as the field separator. By default that separator is a space. (info:coreutils#sort invocation)
For some reason, my ~/ folder had permissions drwxrws---
To fix it I did
#+BEGIN_SRC bash :exports both cd /home/; chmod g-s joshua; ls -lh | grep joshua
#+END_SRC
#+RESULTS:
drwxrwx--- 83 joshua http 4.0K Feb 2 08:04 joshua
The s was magically replaced with a x
find . -name "*org" | grep -r "[pP]rettyhorses"