UNIX script to display the filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX script to display the filename
# 1  
Old 05-07-2015
UNIX script to display the filename

Hi All
How to answer the below interview question..

PHP Code:
With a path and filename of  "/mydir1/mydir2/mydir3/myfilenane.dat" write a UNIX script to display the filename 
# 2  
Old 05-07-2015
This is a bit vague. It's not clear what they want...maybe just to strip off the path...

Suppose you have script that takes the path-filename as arugment 1

Last edited by Corona688; 05-07-2015 at 04:07 PM.. Reason: removing answer to interview question
This User Gave Thanks to blackrageous For This Post:
# 3  
Old 05-07-2015
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Display the Filename and Size of a File

Hello, all! Working in a Bourne shell. What command would list the filename and size of a file if the size of the file had to be bigger than $a and smaller than $b? Output (if $a is 10 bytes and $b is 50 bytes):test1.txt 15 test2.txt 30 test3.txt 50 Thanks, Ann :p (3 Replies)
Discussion started by: LowlyIntern
3 Replies

2. UNIX for Advanced & Expert Users

query display number lines or records present in file only numeric value -without filename

Hi all Thanks in advance........... Please help me for this issue............ I have a file it has 11 records . I used the command like .... >$ wc -l file 11 file I'm getting output like 11 file (no.of records along with filename) here my requirement is, I want to display only... (3 Replies)
Discussion started by: ksrivani
3 Replies

3. UNIX for Dummies Questions & Answers

How to get redirected filename inside unix script

Hi All, I am having a script which calculate checks the input feed and perform some function. When i am executing this script i am redirecting this to a output file. I want to know the redirected output file name inside my scripts. Is there is any way to get that . like the same way we... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

4. Shell Programming and Scripting

How to grep for message and if found display filename?

Hi i'm new to the forum and was hoping someone could help me with the following query. I do alot of testing and have hundreds of log files output. I have a script (someone else wrote) which finds all the passed and failed logs and puts a number in a column onto a webpage: e.g: Pass ... (4 Replies)
Discussion started by: defamer
4 Replies

5. UNIX for Dummies Questions & Answers

how to display date with filename??

Hi i am currently using below command in shell script and calling it from cron job. This is to take daily backup with the date as suffix to the file.When i try i unable to get the date suffixed to the backup file. Please help me as to wt's wrong in this or how to get the date added to the... (5 Replies)
Discussion started by: abhi_n123
5 Replies

6. UNIX for Dummies Questions & Answers

Display last 8 character of filename

I would like to display the last 8 characters of the filenames for filenames of different lengths. I can delete the last 8 characters with sed but dont know how to only show the last 8 characters. The filenames are something like; afxH340800340000 afxH30800340021 afxR3080034002122 I... (3 Replies)
Discussion started by: Beanz
3 Replies

7. Shell Programming and Scripting

display filename with date

Hi buddies, I have a doubt. I want to display filename with date in the following format.Is there any way to do this. Kindly give me the solution. I want to display the result in the following manner. test1.txt 03/28/2008 testlog.log 02/20/2008 Please let me know one solution how to do... (1 Reply)
Discussion started by: pstanand
1 Replies

8. UNIX for Dummies Questions & Answers

Want display a line with space in file by unix script

HI , I am having a file as -----------------a.out------------------- Hi I am unix developer using hp unix this is a test --------------------------------------- i need to read each line by a unix script of the file and to print in console with the space in the line as ... (9 Replies)
Discussion started by: arunkumar_mca
9 Replies

9. Shell Programming and Scripting

Unix shell script (grep -A 6 -B 2 "ORA-" filename

BACKGROUND: I am using Solaris 10. Some of my boxes have gnu grep and I can use -A and -B flags on those. However, the solaris flavor of grep won't use the flags -A or -B. And some of my boxes won't be getting gnu grep. Should I try using perl, awk, or sed? Actual PROBLEM: I am... (7 Replies)
Discussion started by: el_guero
7 Replies

10. UNIX for Dummies Questions & Answers

Display filename and wc stats

I'm just learning UNIX and I'm trying to do the following: Write a script called details.bash that, for each file in the working directory, prints the filename, the # of lines, and the # of words to to some output file, like this: filename1 73 431 filename2 5 21 It's probably a stupid... (1 Reply)
Discussion started by: asianmike
1 Replies
Login or Register to Ask a Question