| ebdev11:shell_scripts$ find . -iname "*pl" -exec grep -l "anyone" '{}' \; -print ./run_bioconcepts_incremental.pl ./run_bioconcepts_incremental.pl ./perl/test_GTRLB.pl ./perl/test_GTRLB.pl ./update_HPO.pl ./update_HPO.pl |
Grep usage
To only print out files ( and not each line in the file that matches the pattern), use grep -l for example:
Remove Icon in MoinMoin before links
1. remove element in common.css and msie.css.
http://moinmo.in/MoinMoinQuestions/Themes#Avoid_Link-Icons_on_linked_images
- One way is to comment out / delete the respective lines in the css sheets. If you don't want the earth-icon remove
a.www:before {content: url(../img/moin-www.png); margin: 0 0.2em;} - from common.css and the corresponding similar line from msie.css.
http://moinmo.in/MoinMoinQuestions/Themes#Avoid_Link-Icons_on_linked_images
Date in Bash Script
To get a nice formatted date in a bash script, use:
http://stackoverflow.com/questions/1401482/yyyy-mm-dd-format-date-in-shell-script
$(date +%F)
There is also
get year-month-day hour:minute:second from date
DATE=`date +%Y-%m-%d`
get year-month-day hour:minute:second from date
DATE=`date +%Y-%m-%d:%H:%M:%S`
http://stackoverflow.com/questions/1401482/yyyy-mm-dd-format-date-in-shell-script
Mirror a Website with WGET
wget -mkEpnp http://example.org
wget --recursive --no-parent --level 3 --execute robots=off -nH example.com
===================================================
wget --mirror --convert-links --adjust-extension --page-requisites
--no-parent http://example.org
Explanation of the various flags:--mirror– Makes (among other things) the download recursive.--convert-links– convert all the links (also to stuff like CSS stylesheets) to relative, so it will be suitable for offline viewing.--adjust-extension– Adds suitable extensions to filenames (htmlorcss) depending on their content-type.--page-requisites– Download things like CSS style-sheets and images required to properly display the page offline.--no-parent– When recursing do not ascend to the parent directory. It useful for restricting the download to only a portion of the site.
wget -mkEpnp http://example.org
Note: that the last
p is part of np (--no-parent) and hence you see p twice in the flags.source: http://www.guyrutenberg.com/2014/05/02/make-offline-mirror-of-a-site-using-wget/
also note the -w flag:
wget -mk -w 1 http://www.example.com
-mk will do mirroring
-w 1 wait 1 second in between downloads
Nohup and Screen
One can use nohup to run files that won't exit when the shell closes; also check out screen!
$ nohup ./somescript.sh &
$ screen -A -m -d -S somename ./somescript.sh &
also see: http://en.wikipedia.org/wiki/Nohup, Advanced Bash Scripting Guide
Vim Hints/Tips
Line Numbering
(Enable)
:set number
:set nu
(Disable)
:set nonumber
:set nonu
:set !nu
source: http://vim.wikia.com/wiki/Display_line_numbers
PerlBestPractices
(.vimrc)
Shiftwidth
Autoindent
Solarized (coloring)
FileFormat
:set ff=unix [unix|dos|mac]
Enabling Options
http://vim.wikia.com/wiki/Managing_set_options
(Enable)
:set number
:set nu
(Disable)
:set nonumber
:set nonu
:set !nu
source: http://vim.wikia.com/wiki/Display_line_numbers
PerlBestPractices
(.vimrc)
Shiftwidth
Autoindent
Solarized (coloring)
FileFormat
:set ff=unix [unix|dos|mac]
dos <CR> <NL> unix <NL> mac <CR>
Enabling Options
http://vim.wikia.com/wiki/Managing_set_options
Miscellaneous
test file format using vim (:set ff?)
solarized and coloring terminals
svn and SVN_EDITOR
Apple/Macs use .bash_profile, not .bashrc (so add link)
solarized and coloring terminals
svn and SVN_EDITOR
Apple/Macs use .bash_profile, not .bashrc (so add link)
Make Offline Mirror of a Site Using `wget`
Use wget to make an offline mirror of a website
wget --mirror --convert-links --adjust-extension --page-requisites
--no-parent http://example.org
Explanation of the various flags:
--mirror– Makes (among other things) the download recursive.--convert-links– convert all the links (also to stuff like CSS stylesheets) to relative, so it will be suitable for offline viewing.--adjust-extension– Adds suitable extensions to filenames (htmlorcss) depending on their content-type.--page-requisites– Download things like CSS style-sheets and images required to properly display the page offline.--no-parent– When recursing do not ascend to the parent directory. It useful for restricting the download to only a portion of the site.
Alternatively, the command above may be shortened:
wget -mkEpnp http://example.org
Note: that the last
p is part of np (--no-parent) and hence you see p twice in the flags.Configuring KDE to Have Desktop Icons Appear
On the desktop, select "Activities" (either on the menu bar at the bottom of the screen, or on the upper right corner box). Select "+ Create Activity" -> "Templates" -> "Desktop Icons". This selects the new activity "Desktop Icons"; this makes a new icon to appear "Desktop Icon"; when selected, will have the desktop icons appear and when "Desktop" activity is selected, the default desktop with a panel showing the Desktop folder appear.
Steam on Fedora 20
RPM packages are available from RPMFusion for all supported Fedora releases. The package works fine on both i686 and x86_64 systems and already contains support for the S3 Texture compression library for open source drivers (radeon, intel and nouveau) along with all the required libraries to start playing with Steam games.
To install, after enabling the RPMFusion repositories, simply issue
Source: Valve
sudo yum install steamNote: There is also a staging repository where additional options are added to the package, like Valve's xpad driver and packages for running the SteamOS client in SteamOS mode. These features might not end up in RPMFusion. The repository is available at negativo17.org.
Source: Valve
Install .deb on Fedora 20
To install a debian package, you first need to convert it from a .deb package to a .rpm package (you may need to install alien first via sudo yum install alien which installs a bunch of perl modules...)
Then do the standard yum install:
>$ alien -r package.deb
Then do the standard yum install:
>$ sudo yum localinstall package.rpm
Moka Themes and Icons on Fedora 20
The Moka themes that are installed by default via fedy are obsolete. The current Moka project repositories can be found at http://mokaproject.com/ .
First, install the repository:
First, install the repository:
su -c "yum-config-manager --add-repo http://mokaproject.com/packages/rpm/moka-stable.repo"Then you can install the individual parts.
- faba-icon-theme
- faba-mono-icons (these are supplemental icons)
- moka-icon-theme
- moka-gnome-shell-theme
- orchis-gtk-theme (requires the Murrine, but it is likely installed: yum search gtk-murrine-engine)
- moka-cinnamon-theme (!) Update! I don't need moka-cinnamon-theme because Fedora 20 uses gnome-shell - cinnamon is a fork of gnome-shell. Don't bother with this one!
(!) Warning! I got "No package moka-cinnamon-theme available" when I tried to install this. And indeed, when I went and browsed the repo - I didn't see it under (http://mokaproject.com/packages/rpm/). But, one can download a package (.zip) and install it that way; see note below.
Instal an individual component like so:
su -c "yum install moka-icon-theme"
Notes:
- Faba's purpose is to serve as a base icon theme to others (such as Moka). It comprises only of a system icons –folders, mimetypes, toolbar icons, etc. To fully experience Moka, it is recommended that you also install Faba Icon Theme.
- The method shown here is Fedora 20 distribution specific. There are agnostic methods for installation.
-
UPDATE! Don't bother with moka-cinnamon-theme!
For reference though, I've kept my notes below.
Because the "preferred" method of downloading the archive doesn't work, I've downloaded the package (moka-cinnamon-theme.zip) and then installed it manually. One can run it as a user and have the theme installed in ~/.themes or as root (so all users can have access to the theme) and it will be installed in /usr/local/share/themes.
Then you may select "Moka" in the Cinnamon theme preferences, or use the following command:gsettings set org.cinnamon.theme name "Moka"
(BTW, it didn't work because I'm not using cinnamon, and it isn't installed! ) - To enable the Moka Gnome Shell Theme, I believe you first need to use "Gnome Tweak Tool" to enable User Themes", and then the Moka Gnome Shell Theme can be selected. See here.
Fedora 20 - uses GNOME-Shell
FYI - Fedora 20 uses GNOME-Shell, not Cinnamon (as I thought earlier)! Cinnamon is a fork of GNOME-Shell and might be used by Mint Linux?
Windows Desktop Icons - Auto Arrange
Problem: the desktop icons don't move (you can't drag and move the icons).
Solution: right click the desktop, click “View”, uncheck “Auto arrange icons”.
Solution: right click the desktop, click “View”, uncheck “Auto arrange icons”.
Ensuring new files in a directory belong to the group
Issue: I want to create a shared directory when a number of users (all belong to a group called mygroup) can create and edit files. I would like all files, including new files created in this directory and subdirectories to belong to the mygroup.
SSH and Port Forwarding
(I) SSH with X. To simply get X over SSH, do
(II) No X? If you installed fedora with minimal package set, you may see:
Here we forward port 1143 on localhost to 143 (IMAP) on imap.example.com.
ssh -X name@machine xterm
(II) No X? If you installed fedora with minimal package set, you may see:
$ ssh -YC remotebox
[major@remotebox ~]$ xterm
xterm: Xt error: Can't open display:
xterm: DISPLAY is not set
source(III) Simple Port Forwarding
Here we forward port 1143 on localhost to 143 (IMAP) on imap.example.com.
- ssh -f -N -q -L 1143:localhost:143 username@imap.example.com
- -f tells ssh to go into the background (daemonize).
- -N tells ssh that you don't want to run a remote command. That is, you only want to forward ports.
- -q tells ssh to be quiet
- -L specifies the port forwarding
Source: Main, Also
How long did that command take to run?
SIMPLE ANSWER
Simply use the command time to see how long it took to execute
$> time cp -R sourcefolder targetfolder
real 0m21.093s
user 0m0.008s
sys 0m0.717s
real - is the full time it took to run the command (how long you waited).
user - is the CPU time used by the program itself.
sys - is the CPU time used by the system calls
Perhaps also see GNU time as an alternative?
Source
POWER ANSWER
Measure time of program execution and store that inside a variable
Simply use the command time to see how long it took to execute
$> time cp -R sourcefolder targetfolder
real 0m21.093s
user 0m0.008s
sys 0m0.717s
real - is the full time it took to run the command (how long you waited).
user - is the CPU time used by the program itself.
sys - is the CPU time used by the system calls
Perhaps also see GNU time as an alternative?
Source
POWER ANSWER
Measure time of program execution and store that inside a variable
usr@srv $ mytime="$(time ( ls ) 2>&1 1>/dev/null )"
usr@srv $ echo "$mytime"
real 0m0.006s
user 0m0.001s
sys 0m0.005s
Perhaps even just use date command, and measure differences from start to finish.Source: unix.stackexchange.comSTART=$(date +%s.%N) command END=$(date +%s.%N) DIFF=$(echo "$END - $START" | bc) # echo $DIFF
RCS - Simple Version Control
RCS is a great simple version control. No need to create repositories. Just use it in place! Create the file, then just check it in (creates initial archived version-controlled file: filename,v). Then just check it out again to do editing.
Check in: $ ci -u inetd.conf
Check out: $ co -l services
Common RCS operations:
Source: O'Reilly: The Five-Minute RCS Tutorial - Automating System Administration with Perl
also see: http://www.yolinux.com/TUTORIALS/LinuxTutorialRCSintro.html
BTW: think co -l as being "locked" from use by other programmers (one edit at a time). It may not be necessary to use -u to unlock the file.
Check in: $ ci -u inetd.conf
Check out: $ co -l services
Common RCS operations:
| RCS operation | Command line |
|---|---|
| Initial check-in of file (leaving file active in filesystem) | ci -u filename |
| Check out with lock | co -l filename |
| Check in and unlock (leaving file active in filesystem) | ci -u filename |
| Display version x.y of a file | co -px.y filename |
| Undo to version x.y (overwrites file active in filesystem with the specified revision) | co -rx.y filename |
| Diff file active in filesystem and last revision | rcsdiff filename |
| Diff versions x.y and x.z | rcsdiff -rx.y -rx.zfilename |
| View log of check-ins | rlog filename |
| Break an RCS lock held by another person on a file | rcs -u filename |
Source: O'Reilly: The Five-Minute RCS Tutorial - Automating System Administration with Perl
also see: http://www.yolinux.com/TUTORIALS/LinuxTutorialRCSintro.html
BTW: think co -l as being "locked" from use by other programmers (one edit at a time). It may not be necessary to use -u to unlock the file.