Sponsored Content
Top Forums Shell Programming and Scripting How to move to the last subdirectory one by one? Post 302961330 by MadeInGermany on Thursday 26th of November 2015 04:01:40 PM
Old 11-26-2015
last is a variable, and holds the previous line.
If the current line does not match the previous line plus a / then print the previous line.
--
I think your script is not correct. The regular-expression match does not like special characters.
At the end of this web page there are some links.
From the "Drilling down to the last subdirecty"
Code:
find . -depth -type d | awk -F/ 'NF>=pnf {print} {pnf=NF}'

It only saves the previous number of fields, and find -depth enforces processing of directories first, so you don't need to sort.

Last edited by MadeInGermany; 11-26-2015 at 05:07 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

subdirectory password

Hi! I am a user of a workstation. I have got my own previlages on my system. Still I would like to have a security for my data. Can I set password or write a script that the entry to a particular subdirectiry is restricted?:confused: (1 Reply)
Discussion started by: sskb
1 Replies

2. Shell Programming and Scripting

Count files in every subdirectory

Hi if anyone could help me :) I did a lot of search and 70% of answer is "how to count files in all subdirectories". A basic problem for me is how to count files in every subdirectory separately then sort it by number of files For example: dir1 file1 file2 subdir11 dir2 dir3 ... (3 Replies)
Discussion started by: yorryk
3 Replies

3. Shell Programming and Scripting

How to deleting some files under subdirectory

Hi guys, sorry if my english not very well.. i have a problem.. i have a file and the structure is : Folder/ Folder/10.123.124.20/pm_data/A200807 Folder/10.123.124.20/pm_data/A200807 Folder/10.123.124.20/pm_data/A200807 Folder/10.123.124.20/pm_data/A200808... (4 Replies)
Discussion started by: AdziE
4 Replies

4. Shell Programming and Scripting

Comparing subdirectory names

I am trying to reformat data from one private directory and reformat it and move it to a public one, but i only want to get directories that have not already been moved to the public directory. Here's what i'm working with Dir1 contains folders for each named with timestamp 20090320081302... (2 Replies)
Discussion started by: dabombace
2 Replies

5. Shell Programming and Scripting

Regex to remove subdirectory

I need to remove subdirectories that are empty and I've not done this before. First I am going through the files to remove old records. Then if the directory is empty I want to delete it. There are files in /direcotry/images/fs* - 0-9 and a-z The fs* directories need to stay, but any directories... (4 Replies)
Discussion started by: janel10
4 Replies

6. UNIX for Dummies Questions & Answers

How to move all files in a directory and subdirectory?

I'm trying to organize my MB Pro by moving all my jpeg files to a single folder from the desktop. There are some on the desktop that are not in any folder. I was at the command line and typed mv *.jpg "Jpeg files" but it only moved the files that were on the desktop, not any of the ones that... (3 Replies)
Discussion started by: Straitsfan
3 Replies

7. UNIX for Dummies Questions & Answers

Listing files in subdirectory

Forgive me if there is an answer to this somewhere in the forums. I've gone through as much as I could but couldn't find a relevant answer. What I'm trying to do is use the ll command to list some files in a subdirectory that matches a certain format. I've tried ll *.*a* <subdirectory> but... (3 Replies)
Discussion started by: archaic
3 Replies

8. UNIX for Dummies Questions & Answers

How to Find files in subdirectory?

I am trying to find all DAT files in a subdirectory named IN. I do not know the entire path. For example: /stage/<?>/<?>/IN/file.DAT I am using the find command without success: find /stage -name IN -a -name '*.DAT' -print What is the correct logic and syntax? Thank you for the help. (5 Replies)
Discussion started by: TwinGT
5 Replies

9. Shell Programming and Scripting

Move all files not in a directory into a subdirectory named for each given file

Hi Everyone! Looking for some help with a script that will take all files in any given root folder (which are not already in a folder) and put them into separate folders with the name of each given file. Any ideas? Thank you! (1 Reply)
Discussion started by: DanTheMan
1 Replies

10. Shell Programming and Scripting

Drilling down to the last subdirectory

Within a BASH environment, I need to search through a filesystem looking for the last subdirectory. Once the last subdirectory of the filesystem is found, I need to create another directory within it: Basic example: /u01/data1/project_1/proj_data1/score... (9 Replies)
Discussion started by: leepet
9 Replies
BMORE(1)						      General Commands Manual							  BMORE(1)

NAME
bmore - browse through a binary file SYNOPSIS
bmore [ -acdi ] [ -n lines ] [ -w cols ] [ +linenumber ] [ +/ASCII-pattern ] [ +Hex-pattern ] [ filename ... ] DESCRIPTION
more is a filter that displays the contents of a binary file on the terminal, one screenful at a time. It normally pauses after each screenful, and prints --More-- at the bottom of the screen. bmore provides a two-line overlap between screens for continuity. If bmore is reading from a file rather than a pipe, the percentage of characters displayed so far is also shown. bmore scrolls up to display one more screen line in response to a RETURN character; it displays another screenful in response to a SPACE character. Other commands are listed below. The screen is divided in three sections or panes: The byte offset (extreme left), the hex pane (middle), and an ascii pane (right) which shows as printable characters those bytes in the hex pane. On an 80 column terminal there will be sixteen hex values and their ASCII val- ues on each screen line. Note that (as one would expect) the first byte has the offset 0 (zero). bmore sets the terminal to noecho mode, so that the output can be continuous. Commands that you type do not normally show up on your ter- minal, except for the / , and ! commands. If the standard output is not a terminal, more acts just like cat(1V), except that a header is printed before each file in a series. OPTIONS
-a ASCII mode: no hex representation of the contents. Non printable characters are displayed as a dot (.) -c Clear before displaying. Redrawing the screen instead of scrolling. -d Display error messages rather than ringing the terminal bell if an unrecognized command is used. This is helpful for inexperienced users. -i Ignore case for searching. -n lines Displays the indicated number of lines in each screenful, rather than the default (the number of lines in the terminal screen less two). -w cols Display number of cols in each line. +linenumber Start up at linenumber. +/ASCII-pattern Start up at the line containing the regular expression pattern. Note: unlike editors, this construct should not end with a `/'. If it does, then the trailing slash is taken as a character in the search pattern. USAGE Commands The commands take effect immediately; it is not necessary to type a carriage return. Up to the time when the command character itself is given, the user may type the line kill character to cancel the numerical argument being formed. In addition, the user may type the erase character to redisplay the `--More--(xx%)' message. In the following commands, i is a numerical argument (1 by default). iSPACE Display another screenful, or i more lines if i is specified. iRETURN Display another line, or i more lines, if specified. i^D (CTRL-D) Display (scroll down) 11 more lines. i is given, the scroll size is set to i. id Same as ^D. iz Same as SPACE, except that i, if present, becomes the new default number of lines per screenful. is Skip i lines and then print a screenful. if Skip i screenfuls and then print a screenful. i^B (CTRL-B) Skip back i screenfuls and then print a screenful. b Same as ^B (CTRL-D). q Q Exit from more. = Display the current line number. v Drop into the bvi(1) editor at the current offset of the current file. w Drop into the bvi(1) editor at the current offset of the current file. Only the portion of the file displayed on the screen will be loaded. h Help. Give a description of all the more commands. i/pattern Search for the ith occurrence of the regular expression pattern. Display the screenful starting at the file position that con- tains the ith match for the regular expression ASCII-pattern, or the end of a pipe, whichever comes first. If bmore is display- ing a file and there is no such match, its position in the file remains unchanged. Regular expressions can be edited using erase and kill characters. Erasing back past the first column cancels the search command. ' Single quote. Go to the point from which the last search started. If no search has been performed in the current file, go to the beginning of the file. !command Invoke a shell to execute command. The characters % and !, when used within command are replaced with the current filename and the previous shell command, respectively. If there is no current filename, % is not expanded. Prepend a backslash to these char- acters to escape expansion. i:n Skip to the ith next filename given in the command line, or to the last filename in the list if i is out of range. i:p Skip to the ith previous filename given in the command line, or to the first filename if i is out of range. If given while more is positioned within a file, go to the beginning of the file. If more is reading from a pipe, more simply rings the terminal bell. :f Display the current filename and offset number. :q :Q Exit from bmore (same as q or Q ). . Dot. Repeat the previous command. FILES /etc/termcap terminal data base /usr/local/share/bmore.help help file SEE ALSO
bvi(1), termcap(5) 3 Jan 2004 BMORE(1)
All times are GMT -4. The time now is 09:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy