09-14-2011
7 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello all,
Can somebody explain to me how set up a basename and dirname variable to simplify this script. I currently have a 'infile' with the contents of FTTPDataPVC_ & BaaisDSLFeed. I need to add a basename and or dirname variable so that any additions can be made through the infile and not... (1 Reply)
Discussion started by: liketheshell
1 Replies
2. Shell Programming and Scripting
I need to get the full path of a file minus the hostname... anyone have an easy way to do this?
What I have is:
//ourhostname/ourfullpath/filename
What I need is:
/ourfullpath/filename
hostname evaluates to 'ourhostname'
dirname evaluates to '//ourhostname/ourfullpath'
basename... (2 Replies)
Discussion started by: tink
2 Replies
3. Shell Programming and Scripting
Hi guys, last cry for help for today. I appreciate the help so far.
ok so I have a program that dumps a path into my script as a variable ($1)
This path is an example
/home/xbmc/sab_downloads/video/tv/grey's anatomy/season 3
So in order to search thetvdb.com for a show, I need to extract... (6 Replies)
Discussion started by: tret
6 Replies
4. Shell Programming and Scripting
Hi all,
my problem:
(little extract from my bash-script)
I want to move each file (.mov) from one directory (and many Subdirectories) to another directory (only one);
after moving i want to create hardlinks to the old directories.
Thatīs no problem, but now:
source-directories... (4 Replies)
Discussion started by: tubian
4 Replies
5. Programming
Hi
I faced with some interesting behavior of basename and dirname functions from libgen.h: they changes the value of argument! Here is the declaration:
char *basename(char *);
char *dirname(char *);It makes some tiresome to use them... I am new to C and maybe I do something wrong, but to... (4 Replies)
Discussion started by: Sapfeer
4 Replies
6. Shell Programming and Scripting
We are using #!/bin/sh
From a command line this command returns the correct list of files (without going into any subdirectories)
find /vol.prod/saptrans/common/test/pa/* -prune -type f -print
We have a script which takes the same path as $1 (without the * )
... (2 Replies)
Discussion started by: 15a0
2 Replies
7. Shell Programming and Scripting
Hello,
I have a list of files generated like this:
find dir -type f > file_list
I want to get a list of just the unique directories. I can't create a temporary file. So the idea is to do a working equivalent to this:
cat file_list | dirname | uniq
But of course that doesn't... (4 Replies)
Discussion started by: brsett
4 Replies
LEARN ABOUT MOJAVE
dirname
DIRNAME(3) BSD Library Functions Manual DIRNAME(3)
NAME
dirname -- extract the directory part of a pathname
SYNOPSIS
#include <libgen.h>
char *
dirname(char *path);
char *
dirname_r(const char *path, char *dname);
DESCRIPTION
The dirname() function is the converse of basename(3); it returns a pointer to the parent directory of the pathname pointed to by path. Any
trailing '/' characters are not counted as part of the directory name. If path is a null pointer, the empty string, or contains no '/' char-
acters, dirname() returns a pointer to the string ".", signifying the current directory.
IMPLEMENTATION NOTES
The dirname() function returns a pointer to internal storage space allocated on the first call that will be overwritten by subsequent calls.
dirname_r() is therefore preferred for threaded applications.
Other vendor implementations of dirname() may modify the contents of the string passed to dirname(); if portability is desired, this should
be taken into account when writing code which calls this function.
LEGACY SYNOPSIS
#include <libgen.h>
char *
dirname(const char *path);
In legacy mode, path will not be changed.
RETURN VALUES
On successful completion, dirname() returns a pointer to the parent directory of path.
If dirname() fails, a null pointer is returned and the global variable errno is set to indicate the error.
ERRORS
The following error codes may be set in errno:
[ENAMETOOLONG] The path component to be returned was larger than MAXPATHLEN.
[ENOMEM] The static buffer used for storing the path in dirname() could not be allocated.
SEE ALSO
basename(1), dirname(1), basename(3), compat(5)
STANDARDS
The dirname() function conforms to X/Open Portability Guide Issue 4, Version 2 (``XPG4.2'').
HISTORY
The dirname() function first appeared in OpenBSD 2.2 and FreeBSD 4.2. The dirname_r() function first appeared in OS X 10.12.
AUTHORS
Todd C. Miller
BSD
October 12, 2006 BSD