Sponsored Content
Full Discussion: Parse Directory path - awk
Top Forums Shell Programming and Scripting Parse Directory path - awk Post 303039553 by RudiC on Wednesday 9th of October 2019 08:37:37 AM
Old 10-09-2019
Will the data follow a certain sequence, i.e. parent dirs sorted, parent dir before child dir, non-empty $3 before empty $3, non-empty $4 before empty $4?
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse value from multiple row to create the path

Hi all, Hope all the expert can help me in this situation. Let say I have one file with multiple record like below: NAME=FRAGMENT LANGUAGE=1 DIALECT=0 GENDER=NONE FILE=TEST1 DIRECTORY=D:/DETAILS/1/0/test1.txt END NAME=FRAGMENT LANGUAGE=1 DIALECT=0 GENDER=NONE (13 Replies)
Discussion started by: shirleyeow
13 Replies

2. UNIX for Dummies Questions & Answers

awk to parse a directory name?

Hi, I have a directory file name: /auto/space/user/jen/CED/CED_01MZ/visit1/DCE_2eco/016/echo1 I would like to just get the following outputs into variables such that: variable1 = /auto/space/user/jen/CED/CED_01MZ/visit1/ and variable2 = DCE_2eco/016/echo1 I've tried it with... (2 Replies)
Discussion started by: nixjennings
2 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

sed/awk for extracting directory from file path

Hi, I have following path: set file_path = D:/forums/prac/somedir/new1/file1.txt or set file_path = E:/new/forums1/prac/somedir/new2/file2.txt I need to grep "somedir" from file path. In this case preceding directory "prac" remains same for both the paths, but directories preceding... (7 Replies)
Discussion started by: sarbjit
7 Replies

5. Shell Programming and Scripting

Parse file name out of UNC path

Hello, I searched the forums and didn't see a situation like this: I cannot figure out how to parse out just the file name from the full path. The path looks like this: \\foo\bar\filename.ext I don't think something like 'cut' will work so I tried to whip up a regex but couldn't get it... (12 Replies)
Discussion started by: bytesnoop
12 Replies

6. Shell Programming and Scripting

Parse output path to set variable

I am looking to parse a text file output and set variables based on what is cropped from the parsing. Below is my script I am looking to add this feature too. All it does is scan a certain area of users directories for anyone using up more than X amount of disk space. It then writes to the... (4 Replies)
Discussion started by: es760
4 Replies

7. Shell Programming and Scripting

Variable of Path directory is not parsing in awk

Hi All, i had to split one files into 10 equally. For that i have coded below awk. OUTPUT_FILE=/home/sit/path/Files/file_EXPORT.lst DIR_NM=`dirname ${OUTPUT_FILE}` awk -v CURR_DATE="$(date +'%d-%m-%Y-%H-%M')" -v pth=$DIR_NM '{print >> pth/"tgt_file_name"CURR_DATE"_"NR%10 }' ${OUTPUT_FILE} ... (7 Replies)
Discussion started by: looney
7 Replies

8. 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

9. 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
RMDIR(P)						     POSIX Programmer's Manual							  RMDIR(P)

NAME
rmdir - remove directories SYNOPSIS
rmdir [-p] dir... DESCRIPTION
The rmdir utility shall remove the directory entry specified by each dir operand. For each dir operand, the rmdir utility shall perform actions equivalent to the rmdir() function called with the dir operand as its only argument. Directories shall be processed in the order specified. If a directory and a subdirectory of that directory are specified in a single invo- cation of the rmdir utility, the application shall specify the subdirectory before the parent directory so that the parent directory will be empty when the rmdir utility tries to remove it. OPTIONS
The rmdir utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines. The following option shall be supported: -p Remove all directories in a pathname. For each dir operand: 1. The directory entry it names shall be removed. 2. If the dir operand includes more than one pathname component, effects equivalent to the following command shall occur: rmdir -p $(dirname dir) OPERANDS
The following operand shall be supported: dir A pathname of an empty directory to be removed. STDIN
Not used. INPUT FILES
None. ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of rmdir: LANG Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE Std 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments). LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES . ASYNCHRONOUS EVENTS
Default. STDOUT
Not used. STDERR
The standard error shall be used only for diagnostic messages. OUTPUT FILES
None. EXTENDED DESCRIPTION
None. EXIT STATUS
The following exit values shall be returned: 0 Each directory entry specified by a dir operand was removed successfully. >0 An error occurred. CONSEQUENCES OF ERRORS
Default. The following sections are informative. APPLICATION USAGE
The definition of an empty directory is one that contains, at most, directory entries for dot and dot-dot. EXAMPLES
If a directory a in the current directory is empty except it contains a directory b and a/b is empty except it contains a directory c: rmdir -p a/b/c removes all three directories. RATIONALE
On historical System V systems, the -p option also caused a message to be written to the standard output. The message indicated whether the whole path was removed or whether part of the path remained for some reason. The STDERR section requires this diagnostic when the entire path specified by a dir operand is not removed, but does not allow the status message reporting success to be written as a diagnostic. The rmdir utility on System V also included a -s option that suppressed the informational message output by the -p option. This option has been omitted because the informational message is not specified by this volume of IEEE Std 1003.1-2001. FUTURE DIRECTIONS
None. SEE ALSO
rm , the System Interfaces volume of IEEE Std 1003.1-2001, remove(), rmdir(), unlink() COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 RMDIR(P)
All times are GMT -4. The time now is 02:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy