LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices



Old

Getting Absolute Paths of UNIX Directories and Filenames in Shell Scripts

Posted 07-08-2011 at 04:05 AM by konsolebox
Updated 07-17-2011 at 10:11 AM 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 (3.0 and newer only)
Code:
function getabspath {
	local -a T1 T2
	local -i I=0
	local IFS=/ A

	case "$1" in
	/*)
		read -r -a T1 <<< "$1"
		;;
	*)
		read
...
Senior Member
Posted in Howtos
Views 1918 Comments 0 konsolebox is offline
Old

If - how to use

Posted 12-05-2008 at 03:27 AM by kshfi (Jukka's script corner)
Updated 12-07-2008 at 10:57 AM by kshfi
Tags bash, ksh

Programmers - shell if is command.

Code:
if command exit code is 0
then
    do something 1
    do something 2
fi
Ex.
Code:
if  cp fromfile tofile
then
   echo "Works fine"
else
   echo "Error ???"
fi
[ = test
You can write test or [

Code:
a=1
b=1
test "$a" = "$b"
echo $?
0

a=1
b=2
...
LQ Newbie
Views 1186 Comments 0 kshfi is offline

  



All times are GMT -5. The time now is 12:05 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration