LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices


Old

Comment a block in shell

Posted 08-31-2011 at 12:22 AM by hi2arun
Tags bash, script

We all know, to comment out a line in shell script, '#' token is inserted in the line that needs to be made dead.
Eg:

Code:
# This is a dead line
echo "This line is live"
However, '#' token can be pesky if a block of lines need to be commented out.
Say, to comment out the following block using '#'

Code:
# comment starts here
# All these lines
# are blocked
# using '#' token
# ...
# ...
# ...
...
Member
Posted in Uncategorized
Views 1344 Comments 0 hi2arun is offline
Old

Getting Absolute Paths of UNIX Directories and Filenames in Shell Scripts

Posted 07-08-2011 at 03:05 AM by konsolebox
Updated 05-27-2018 at 03:20 PM by konsolebox
Tags bash, ksh, script, shell, zsh

This post is a compilation of the function getabspath() for different shells that can be used to get the absolute form of a path. The function accepts an argument path then returns the absolute form of it to the variable $__.

Bash
Code:
function getabspath {
	local t=() i=0 IFS=/

	case $1 in
	/*)
		__=${1#/}
		;;
	*)
		__=${PWD#/}/$1
		;;
	esac

	case $- in
	*f*)
		set -- $__
...
Senior Member
Posted in Howtos
Views 4308 Comments 0 konsolebox is offline
Old

Shortest command to calculate the sum of a column of output

Posted 06-02-2010 at 06:27 AM by bittner (Notes on Linux)

I had to calculate the Installed-Size for a .deb control file recently. Here is the solution I came up with:

Code:
dpkg-deb -c mypackage.deb | sed -e 's/.*root\s*//' -e 's/\s*2010-.*$//' | xargs | tr ' ' + | bc
What it does? The code tries to construct a calculation string and feeds it to the command line calculator bc as follows:
  1. use dpkg-deb to get the file size information out of the Debian package
  2. sed away all characters before and after the
...
LQ Newbie
Posted in Uncategorized
Views 7976 Comments 2 bittner is offline
Old

Unix runlevel scripts: Finally the first character makes sense!

Posted 05-29-2010 at 04:12 PM by bittner (Notes on Linux)

You probably know Unix runlevel scripts. They start with an S or a K, and they are typically located at /etc/rcX.d/ with X being the runlevel (0-6) the script is supposed to run at. For example:
Code:
~$ ls -l /etc/rc5.d/*cups
lrwxrwxrwx 1 root root 14 2009-12-31 16:35 /etc/rc5.d/S50cups -> ../init.d/cups
To be precise those S- and K- files are typically symbolic links to scripts that reside in /etc/init.d/, and from my experience I felt they work as follows:
  • Any symlink
...
LQ Newbie
Posted in Uncategorized
Views 3319 Comments 0 bittner is offline
Old
Rating: 2 votes, 5.00 average.

[script] Easy Backup Solution using rsync

Posted 01-03-2010 at 10:03 AM by ~sHyLoCk~
Updated 01-05-2010 at 10:14 PM by ~sHyLoCk~

Originally Posted in my Blog.

I will be writing this guide as a part of my upcoming "Arch System Maintenance Guide". When you are using Linux, you should always take regular backups. It is secure, it is stable and all that, but backup is very important to aid you in case you make a mess of your system. I will be writing the script to backup the entire system, excluding a few folders/files,etc. So here...
Senior Member
Posted in Scripts
Views 4750 Comments 0 ~sHyLoCk~ is offline

  



All times are GMT -5. The time now is 09:29 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration