Solved

List only file name

Posted on 2007-11-26
1
8,539 Views
Last Modified: 2013-11-17
Is there a way in AIX to only list the file name?

If I run the command below, only the file name is displayed.
ls -1 /tmp/

If I run the command like this, the path is included in the file name.   How can I get only the file name like the first command above?
ls -1 /tmp/*.txt
0
Comment
Question by:Quetysis
1 Comment
 
LVL 3

Accepted Solution

by:
amirs80 earned 500 total points
ID: 20356629
use this command

#ls /tmp/*.txt | awk -F/ '{ print $3 }'

if your directory is changed, suppose /var/log
then the argument is changed

#ls /tmp/*.txt | awk -F/ '{ print $4 }'

means increase in dir depth, increase the number of argument
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now