Solved

List only file name

Posted on 2007-11-26
1
8,536 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…

746 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

9 Experts available now in Live!

Get 1:1 Help Now