- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting Novice
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2009 02:47 AM
тАО02-17-2009 02:47 AM
I am still a scripting novice and so it still cause me headaches doing the easiest stuff. I wonder if you can help.
I want to pull out an long listing of a directory (not my current working dir) but filter out anything that is a directory. So i thought about using the command;
ls -lp | grep -v /
This works fine on the current working directory, but i wonder how i can integrate this into a script to get this listing from another directory.
Or please can you offer any other ways of getting a listing of just the files only in a directory, without it being your current working directory.
PS: Dont know if it makes any difference but it will have to be issued by sudo, so the command will be something like;
sudo -u root
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2009 03:07 AM
тАО02-17-2009 03:07 AM
Re: Scripting Novice
Try this instead:
ll | grep -v "^d"
>but it will have to be issued by sudo
It shouldn't make a difference, unless /usr/bin isn't in root's path. (No /sbin/ll.)
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2009 03:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2009 03:17 AM
тАО02-17-2009 03:17 AM
Re: Scripting Novice
if you want all the file in a directory you could do
find $DIRECTORY -type f
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2009 03:36 AM
тАО02-17-2009 03:36 AM
Re: Scripting Novice
If you want to long list only files on specific directory, use this command
#ll
Ex: ll /tmp |grep -v ^d
With sudo
#sudo -u root ll /tmp |grep -v ^d
Ganesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2009 03:39 AM
тАО02-17-2009 03:39 AM
Re: Scripting Novice
And thanks for the explanation Mark of what it actually does.
But one more quick question.
If i wanted to run that command ll | grep -v "^d" on a directory that was not my current working directory could that be done? I am guessing so but i just can figure it out as simply doing that command followed by a directory doesnt work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2009 03:40 AM
тАО02-17-2009 03:40 AM
Re: Scripting Novice
I will assign points and then close the call.
Thanks Again everyone......
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2009 03:41 AM
тАО02-17-2009 03:41 AM
Re: Scripting Novice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-17-2009 04:08 AM
тАО02-17-2009 04:08 AM
Re: Scripting Novice
cd into the directory before running the command.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-18-2009 01:53 AM
тАО02-18-2009 01:53 AM
Re: Scripting Novice
find
find
and find has many options which will get you were you want to go next.
- Tags:
- find