Vi Tip: Search and Replace Text
There are times when you would like to change text within a specific range:
First show the line numbers using;
:set nu
Then do the search and replace task like so:
:start_line,end_lines/text_to_be_searched_for_and_replaced/replacing_text/g
First show the line numbers using;
:set nu
Then do the search and replace task like so:
:start_line,end_lines/text_to_be_searched_for_and_replaced/replacing_text/g
Modifying multiple files in one stroke
The other day, I was working on code and felt that I had to change the
date creation function and make use of SQLAlchemy's server_default =
text("sysdate") from a rather bizare default = datetime.now()
so I run this;
sed -e 's/default = datetime.now()/server_default = text("sysdate")/g' -i models/*.py
and all python files were updated
so I run this;
sed -e 's/default = datetime.now()/server_default = text("sysdate")/g' -i models/*.py
and all python files were updated
Bash: List of commands (Executing Commands Sequentially)
The bash shell has an interesting feature where one is able to execute a list of commands sequentially. A list refers to a sequence of one or more commands that are separated by the following operators; '&', '&&', '||', ';', or the new line character.Bash Tips: Command History
There are several ways of working with command line history in a bash shell. The history command helps you check what commands have been typed previously. The bash command line history is usually stored in the file .bash_history in a user's home directory (that is; if you use bash as your user shell-which is true for Linux (I run the 3.0.0.12 kernel). You can check which shell is your default from the /etc/passwd file. It is usually the last value after the last colon on your username line e.g:user_name:x:1000:1000:FirstName LastName,,,:/home/my_user_name:/bin/bash
The command line history is controlled by HISTSIZE and HISTFILE environment variables...
Vi Tip: Prepending Text to multiple lines
There are cases when you want (for many
reasons), to add same text to the beginning of multiple lines. This
may happen when you are coding (say python) and then you
realise that you need to enclose your function within a class. So you
add the class definition at the start of the module file. You then
need to indent the function, as python requires. To indent you need
to add four spaces (or your preferred number). In vi, you do this
like so;Limiting the number of simultaneous user logins
When a user is created, the user generally has an unlimited number of simultaneous logins. This, I think, is generally not a good idea. There should be a limit to the number of virtual terminals that a user can open simultaneously. Those users who just cannot resist opening many terminals should seriously consider installing screen. Read on...VirtualBox: Managing Virtual Machines In Headless Mode
Virtual Box is a virtualization software that allows many operating systems (guests) to run simultaneously on a host operating system. In the concept of cloud computing, virtualization has become the "in-thing". It is increasingly common for applications to be run on different virtual machines running on one physical machine/server. The guest operating systems (Virtual Machines) can be run in either headed or headless modes. The difference is that in "Headed" mode, the guest displays an interface similar to that displayed when the monitor is connected to the system. More...Kismet: Ultimate Access Point Discovery Tool
Kismet
is an absolutely incredible piece of software for Linux boxes to
discover any wireless access points (AP) in your neighborhood. Even if
the AP does not broadcast anything and is pretending to hide, kismet
will bust it. Mac users have kismac.Kismet
is one of the ultra modern wireless sniffers. It can and should be used
in together with others such as aircrack-ng, airodump, airdecap,
airreplay and others. I view these applications as complementary rather
than competing. Just read on
Remove files or directories in Linux
This
is a comprehensive way to remove/ delete files/ directories from
konsole, or Terminal (whatever you call your command line). `rm' removes
each given FILE. By default, it does not remove directories. rm short
form of remove deletes directories and files from your disk.