473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

New Kid on the blog and Linux too---need help

Can somebody help me with a sript to print the parent directory and sub directory name for a given directory. It should not print the file names inside the directories. I want only the directories name.
Mar 27 '08 #1
3 1552
micmast
144 100+
you might be able to solve this with simple command line tools

all the subdirs
$> ls -lR | grep ^d

parent folder:
$>pwd
then do some cutting
Mar 27 '08 #2
Laharl
849 Expert 512MB
To avoid the cutting, you could cd .. before using pwd, as that would give you the exact directory. You'd need to hold the previous directory in a variable so that you could cd back to it, but it would still probably be simpler.
Mar 28 '08 #3
prn
254 Expert 100+
Can somebody help me with a sript to print the parent directory and sub directory name for a given directory. It should not print the file names inside the directories. I want only the directories name.
I'm a bit suspicious of the phrase "given directory". How is it "given"? My guess (and this may be entirely wrong) is simply that it means you know the name of a specific directory, e.g. /var/log/mail and you want to parse that into its own name "mail" and its parent's path name "/var/log" Is that what this is about?

If so, then check the commands "basename" and "dirname" as in:
Expand|Select|Wrap|Line Numbers
  1. [prn@deimos ~]$ basename /var/log/mail
  2. mail
  3. [prn@deimos ~]$ dirname /var/log/mail
  4. /var/log
If this is not what you're trying to do, please clarify your question.

Best Regards,
Paul
Apr 9 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ashokrathi | last post by:
I am trying to compile SQL procedures on Linux running on AMD/Opteron 64-bit machine. I have 'gcc', 'cc' and 'g++' compilers on my machine. I have set DB2_SQLROUTINE_COMPILE_COMMAND with various...
3
by: Robert Smith | last post by:
As you can tell by my code that I will post I am obviously new with linux socket programming so to be to hard on me :) When I run my little program I get this error: Server: got connection from...
8
by: shenanwei | last post by:
I have DB2 v8.1.0.0 currently on Redhat 8.0 box. Want to upgrade it to V8.2, downloaded FP10_MI00138_RTCL.tar from IBM. Extracted and run db2_install, get the following error. # ./db2_install ...
1
by: Paul Rubin | last post by:
In Windows if you click the Help dropdown, IDLE launches a help window as it should. The help contents are included in the installation. In Linux, clicking Help launches a web browser, which is...
2
by: rasmidas2004 | last post by:
1. which process is the parent process of all the processes in Linux? 2.How the system calls are getting called? 3. If there are different terminals attached to the system the if more than one...
3
by: Chrisp | last post by:
Hi! I haven't adapted to Linux yet (as much as I would like to) and I haven't installed any programmes on Linux too... I have downloaded qt-x11-opensource-src-4.2.2.tar.gz I extracted file in...
2
by: jesmi | last post by:
hello i want to learn linux. i don't have any ideas regarding linux. please help me with some linux commands for the beginner. thank you jesmi
1
by: hmiller | last post by:
Greetings all, Is anybody familiar with the Unify Dataserver ELS Database? I have some old, old Unify database data files that I had pulled from a Unix machine. I have them on a Red Hat Linux...
6
AmberJain
by: AmberJain | last post by:
I have installed Red Hat linux a few days ago and then I accessed ext3/ext2 partitions (on which linux is installed) from windows using some third party software. Now I wanna access FAT32...
3
by: harvindersingh | last post by:
Hello everyone, I am trying to convert characters in a file using SED, I have already got the script working there is one very big problem. I would like to convert characters in the given file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.