Sponsored Content
Top Forums Shell Programming and Scripting How to get last directory path in script Post 302669123 by vel4ever on Tuesday 10th of July 2012 12:32:49 PM
Old 07-10-2012
This directory name is located in environment variable. I get it from there in my shell script.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to get directory name from its path?

If I the path to a directory, what command can I use to return the actual name of that directory. test=`pwd`/folder1 > $test folder1 I'd rather avoid anything with regular expressions. Any ideas? (1 Reply)
Discussion started by: ordano
1 Replies

2. Shell Programming and Scripting

absolute path for a script ran with relative path

I have a script in which i want to print absolute path of the same script irrespective of path from where i run script. I am using test.sh: echo "pwd : `pwd`" echo "script name: $0" echo "dirname: `dirname $0`" when i run script from /my/test/dir/struct as ../test.sh the output i... (10 Replies)
Discussion started by: rss67
10 Replies

3. Shell Programming and Scripting

Retrieve directory path from full file path through sh

Hi, I have a file abcd.txt which has contents in the form of full path file names i.e. $home> vi abcd.txt /a/b/c/r1.txt /q/w/e/r2.txt /z/x/c/r3.txt Now I want to retrieve only the directory path name for each row i.e /a/b/c/ /q/w/e/ How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies

4. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

5. Shell Programming and Scripting

Error when using certain directory path

Hi, I am using the following code to check if directory is empty: if ; then echo "There is no files in the input" sleep 60 fi And indir path is: /CH_ROOT/PRD/MAIN/INPUT/SDNTL/Interconnect Only when I am using the above path I get an error "too many arguments". I tried with 10... (4 Replies)
Discussion started by: apenkov
4 Replies

6. Shell Programming and Scripting

Keep last directory from path

Hello, I am looking for a command that will give me the last directory name from a path ex 1 : /dir1/dir/2/dir3/ output needed dir3 ex 2 : /dir1/dir/2/dir3/dir4/ output needed dir4 (1 Reply)
Discussion started by: Aswex
1 Replies

7. UNIX for Dummies Questions & Answers

Extract directory name from the full directory path in UNIX using shell scripting

My input is as below : /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt /splunk/scrubbed/triumph/ifind.triumph.txt From the above input I want to extract the file names only . Basically I want to... (5 Replies)
Discussion started by: IshuGupta
5 Replies

8. Shell Programming and Scripting

Pass File name and Directory Path through command to python script

I'm writing python script to get the file-names in the current directory and file sizes .I'm able to get file list and their sizes but unable to pass them through command line. I want to use this script to execute on other directory and pass directory path with file name through command line. Any... (1 Reply)
Discussion started by: etldeveloper
1 Replies

9. UNIX for Beginners Questions & Answers

Convert Relative path to Absolute path, without changing directory to the file location.

Hello, I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies

10. UNIX for Beginners Questions & Answers

What is the difference ../directory path and ./directory path in ksh?

What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies
chroot(8)						      System Manager's Manual							 chroot(8)

NAME
chroot - Changes the root directory of a command SYNOPSIS
/usr/sbin/chroot directory command DESCRIPTION
Only root can use the chroot command. The chroot command changes the root directory from / to the specified directory when the command executes. (The command specified includes both the command name as well as any arguments.) Consequently, the root of any path (as indicated by the first / (slash) in the pathname) changes to directory and is always relative to the current root. Even if the chroot command is in effect, directory is relative to the current root of the running process. Several programs may not operate properly after chroot executes. You must ensure that all vital files are present in the new root file system and the relevant pathnames for the files map correctly in the new root file system. For example, the ls -l command fails to give user and group names if the new root file system does not have a copy of the /etc/passwd and /etc/group files. If the /etc/passwd and /etc/group files in the new root file system represent different user and group names, then the output from the ls -l command will be based on those names, not the ones for the system's own name database. Utilities that depend on description files produced by the ctab command may also fail if the required description files are not present in the new root file system. The chroot program uses the execv() function to invoke the specified command. As a consequence, the command specified must be an exe- cutable binary, not a shell script. Further, if the program requires indirect loading (for example, due to unresolved symbols requiring use of a shared library), then /sbin/loader as well as any files it requires (for example, shared libraries) must be present in the new root file system in the appropriate locations. EXAMPLES
To run a subshell with another file system as the root, enter a command similar to the following. Note in this example, the file system is on the /dev/disk/dsk13a device and is mounted to /mnt/dsk13a: chroot /mnt/dsk13a /sbin/sh The command shown in the previous example spec- ifies a change from the current root file system to the one mounted on /mnt/dsk13a while /sbin/sh (which itself is relative to the new root file system) executes. When /bin/sh executes, the original root file system is inaccessible. The file system mounted on /mnt/dsk13a must contain the standard directories of a root file system. In particular, the shell looks for commands in /sbin, /bin, and /usr/bin (among others) on the new root file system. Running the /sbin/sh command creates a subshell that runs as a separate process from the original shell. Press to exit the subshell and return to the original shell. This restores the environment of the original shell, including the meanings of the current directory (.) and the root directory (/). To run a command in another root file system and save the output on the initial root file system, enter a command similar to the following. Note in this example, the file system is on the /dev/disk/dsk13a device and is mounted to /mnt/dsk13a: chroot /mnt/dsk13a /bin/cc -E /u/bob/prog.c > prep.out The previous command runs the /bin/cc command with /mnt/dsk13a as the specified root file system. It compiles the /mnt/dsk13a/u/bob/prog.c file, reads the #include files from the /mnt/dsk13a/usr/include directory, and puts the compiled text in the prep.out file on the initial root file system. To create a file relative to the original root rather than the new one, use this syntax and enter: chroot directory command > file CAUTIONS
If special files in the new root have different major and minor device numbers than the initial root directory, it is possible to overwrite the file system. FILES
Specifies the command path. RELATED INFORMATION
Commands: cc(1), cpp(1), ls(1), sh(1) Functions: chdir(2), chroot(2) exec(2) delim off chroot(8)
All times are GMT -4. The time now is 12:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy