Tagged: bash Toggle Comment Threads | Keyboard Shortcuts

  • Dimitris Kalopsikakis 08:04 on 10 December 2017 Permalink | Reply
    Tags: bash, , venv, virtual environment   

    Simple script to create a python virtual environment 

    Before running the script, do:

    The script downloads python, compiles it, installs it in $PYINSTALL  and creates  virtual environment in $PYENV :


  • Dimitris Kalopsikakis 06:05 on 25 October 2016 Permalink | Reply
    Tags: bash, inline, , sed   

    Insert a line in the middle of multiple files 

    Suppose you want to insert a line at 10th line of all files in current directory (e.g. all txt files). The following command creates a backup for each file with the extension “.bak” and changes the files inline.


  • Dimitris Kalopsikakis 07:00 on 26 September 2016 Permalink | Reply
    Tags: awk, bash, history   

    Unlimited bash history 


    @ /etc/bash.bashrc

    and @ $HOME


    Generally speaking, it’s very useful to have the history of all commands you have ever typed. However bash keeps only a limited number of commands.There are two environment variables, HISTSIZE και HISTFILESIZE [read: bash(1) ] which define the maximum number of commands and the maximum number  of lines in the history file. In theory, there is no upper bound to the value you cab assign to them. I real life though, mysterious vanishment of data of the history file has been reported around several times.

    A workaround for this, is defining the envirnment variable PROMPT_COMMAND [read: bash(1)]. A good idea is to define that variable at the central bashrc file of the system, /etc/bash.bashrc , so that unlimited history will be available for all users:

    The first line defines the format of the date. The second line, for each expression that we type, tells bash to print the process id ($$) of current bash session, the username ($USER) and the last line of bash history, which is what we just typed. When we cat the file that our unlimited history is stored, we notice that there are a lot of multiple records of the same command. This happens because when we simply press “enter”, the expression  $(history 1)  has always the value of the last command we typed. We workaround this by creating a little script and use that as a history command:

    In this, awk [read: awk(1)] filters out the duplicated lines.

    Unlimited history is a wise practice for servers.


  • Dimitris Kalopsikakis 20:55 on 22 September 2016 Permalink | Reply
    Tags: bash, , libreoffice,   

    Massively convert odt files to pdf 

    In a bash shell,


Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc