Posts with the tag work on the terminal

Create a git repo from .tar.gz files with versions as commits

Say you have a bunch of .tar.gz files, each representing a certain version of a program source code. If you want to compare their contents and see what changed, git would help a lot.

So I wrote a script that would do the work for me and create a repository for...

Read on

calculate pi to a 1000 digits

http://alien.slackbook.org/blog/calculating-pi/

Here is a shell / Bash script that calculates Pi to 1000 digits:

bc -l <<< 'scale=1000; 4*a(1)'
# which is shorter than the equivalent
echo "scale=1000;4*a(1)" | bc -l

One more calculation using bc: the golden ratio to 10 digits:

bc -l...

Read on

control BOINC using the CLI boinccmd

http://boinc.berkeley.edu/wiki/Boinccmd_tool

boinccmd --join_acct_mgr bam.boincstats.com user PASSWORD

If you get Authorization failure: -155 errors all the time, search for files named gui_rpc_auth.cfg and delete them if they are outside the /etc or /var directory.

...

Read on

Convert a String of Hex Values to its Binary Representation Using sed

Suggest you have data in a hex format that you want to convert back to binary (like an MBR) with newline characters in the middle:

eb58904d53444f53352e300002082200
0200000000f800003f00ff0000000000
0000f000e33b00000000000002000000
01000600000000000000000000000000
00002918d163804e4f204e414d452020
2020464154333220202033c98ed1bcf4
7b8ec18ed9bd007c884e028a5640b408
cd137305b9ffff8af1660fb6c640660f
b6d180e23ff7e286cdc0ed0641660fb7
c966f7e1668946f8837e16007538837e
2a007732668b461c6683c00cbb0080b9
0100e82b00e94803a0fa7db47d8bf0ac
84c074173cff7409b40ebb0700cd10eb
eea0fb7debe5a0f97debe098cd16cd19
6660663b46f80f824a00666a00665006
53666810000100807e02000f852000b4
41bbaa558a5640cd130f821c0081fb55
aa0f851400f6c1010f840d00fe4602b4
428a56408bf4cd13b0f9665866586658
6658eb2a6633d2660fb74e1866f7f1fe
c28aca668bd066c1ea10f7761a86d68a
56408ae8c0e4060accb80102cd136661
0f8254ff81c300026640490f8571ffc3
4e544c44522020202020200000000000
00000000000000000000000000000000
00000000000000000000000000000000
0000000000000000000000000d0a5265
6d6f7665206469736b73206f72206f74
686572206d656469612eff0d0a446973
6b206572726f72ff0d0a507265737320
616e79206b657920746f207265737461
72740d0a0000000000accbd8000055aa

Like this you can convert it back to its binary content:

cat datafile.txt | echo -n -e $(tr -d '[:space:]' | sed 's/../\\x&/g')

Resources

  • <a...

Read on

Shortcut to Access the Preview Application from Terminal using AppleScript

If you ever wanted to open PDF, JPEG, PNG files etc.

#!/bin/sh
# A simple bash script that uses Applescript to
# open multiple files in Preview. For example:
# "preview hello.png world.gif *.jpg"

if [ -z "$*" ]; then
 ...

Read on

Bash Aliases ( bashrc , bash_profile and bash_login )

Edit your ~/.bashrc :

#PATH=$PATH:$HOME/bin:/usr/local/bin
alias firefox="open -a Firefox"
alias l="ls -l"
alias la="ls -la"

and reload the .bashrc file using . ~/.bashrc or source ~/.bashrc

You might want to add the following line to your ~/.bash_profile in order to get the ~/.bashrc loaded at the start of an interactive bash session:

[[...

Read on

Terminal Shortcut for Firefox on Mac OS X

http://kb.mozillazine.org/Command_line_arguments

Create a terminal shortcut for Firefox:

sudo ln -s /Applications/Firefox.app/Contents/MacOS/firefox-bin /usr/local/bin/firefox

or simply use the open tool with the application option -a Firefox:

open -a Firefox http://google.de
...

Read on

Creation of ISO images, Burning of ISO images – Both on the Terminal using Mac OS X

Burning an ISO Image from Terminal

hdiutil burn image.iso

Creating an ISO Image from a Folder

hdiutil makehybrid -o ~/Desktop/[outfile] ~/Desktop/[source]

[source] can be a folder or a disk image.

Creating an ISO Image from a CD

Determine the device that is you CD/DVD drive:

drutil status

Umount the disk:

diskutil...

Read on

Spotlight Search and Indexing

Terminal helpers (command line tools):

  • mdfind : Search Spotlight metadata indices.
  • mdimport : Force Spotlight to import metadata for a specific directory.
  • mdls : List the metadata attributes of a specific file.
  • mdutil : A utility for managing Spotlight indices.

To erase and rebuild the index on the root partition / do:

sudo...

Read on

Convert ape audio files to mp3 on the terminal

http://ubuntuforums.org/showthread.php?p=6879960#post6879960

Requirements: Having the executables mac, lame and id3v2 installed.
I haven't done it myself yet, but this seems to be a nice and quick way to do a conversion and set the ID3 tags in the newly created MP3:

#!/bin/bash
echo "Artist name?"
a= <span...

Read on

Split Large Monkey's Audio Files with CUE Sheets into Single Files

Installation:

sudo apt-get install cuetools shntool flac wavpack

Run:

cuebreakpoints sample.cue | shnsplit -o flac sample.flac

In this example, a flac file called sample.flac is split according to the break-points contained in sample.cue and the results are output in the flac format.

To split a monkey’s audio file (.ape) by cue...

Read on

Convert a CUE / BIN CD Image to ISO Format

http://ubuntuforums.org/showthread.php?t=239407 and http://he.fi/bchunk/

A search for tools that can do the conversion

apt-cache search convert cue bin iso

reveals several candidates to fulfill this task:

bchunk - CD image format conversion from bin/cue to iso/cdr
mdf2iso - A simple utility to convert mdf to iso /...

Read on

Search for Strings Inside Files

To search for the string Find me inside text files in the working directory on a UNIX computer, do:

grep "Find me" *.*

or if you want to search in all subdirectories too:

ls `find . -type f -print  | xargs grep -l -s "Find me"`

If you want...

Read on

Save Websites to Mirror a Browsable Version Using wget or webhttrack

using wget

http://www.boutell.com/newfaq/creating/mirroring.html
http://ubuntuforums.org/showthread.php?t=654722&page=2

wget -m -k -K -E http://example.com/

If this command seems to run forever, there may be parts of the site that generate an infinite series of different URLs. You can combat this in many ways, the simplest being to use the -l option to specify...

Read on

Quickshare Folder using SMB and Discover SMB Shares on the Command Line

Gnome 'Share this folder'

Right click the folder you want to share in Gnome → sharing options → Share this folder (maybe this requires the installation of package samba, after installation log out and on again).

Allow SMB Connections In Your Firewall

After configuring firestarter to allow SMB, sudo iptables-save contains:

-A...

Read on

Short Of Disk Space - Find Large Files & Clear Caches

When your hard disk is getting full you might want to know why and what files are the largest. This post describes how to find that out and clean up using the disk usage analyser, package cache cleaning and a fast way to list big files on the terminal using...

Read on

Suspend Using Console

see also: http://wiki.ubuntuusers.de/Schlafmodi

$ sudo /etc/acpi/sleep.sh force

alternatively:

$ sudo echo mem > /sys/power/state

or as gdm does it (see /etc/gdm/gdm.conf → constant SuspendCommand):

$ sudo /usr/sbin/pm-suspend

you can run this script and therefore suspend remotely with ssh option -t to prevent echo on the terminal:

<pre...

Read on