?
Solved

List only file name

Posted on 2007-11-26
1
Medium Priority
?
8,547 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
amirs80 earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

752 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