Ls without extensions.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ls without extensions.
# 1  
Old 03-19-2016
Ls without extensions.

Hello everyone. Smilie I need to write a script and I'm newbie in it.
Sorry for my English, I've been learning that amazing language for one year.

Task:
Write script called 'myls', "wrapper" program call ls in such a way that you could ask it the name of the file without extension, for example: you should write 'myls main' instead of 'ls main.c'. The script should first check if there is a file of exacly that name, and if so, call the program ls with it directly.

If the file doesn't exist, the script should try to make up the name of the file from a predefined list EXTENSIONS=".c .java .html" and if one of them adjusts to the existing file, invoke ls with appropriately name.

You can't call program ls with the name of a nonexistent file.
You can't use programs like: grep, sed, awk, tr.

I really appreciate any help you can provide. Smilie
# 2  
Old 03-19-2016
Rule #6:

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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mv all files with different extensions to a new name

Hello all! I want to move several files foo.aux foo.log foo.pdf foo.tex to bar_foo.aux bar_foo.pdf bar_foo.tex I am on tcsh % mv foo.* bar_!#:1 is not working. Thank you for your help marek (11 Replies)
Discussion started by: marek
11 Replies

2. Shell Programming and Scripting

Checking file extensions

I am trying to store file with certain file extensions to list but having some problems. Here is a part of the code set fryLst = "" set fxtLst = "" foreach f ($AfullNameLst) set fname = $f:r set fext = $f:e if ("$fext" == ".ry") set fryLst = "$fryLst $f" if ("$fext" == ".xt")... (2 Replies)
Discussion started by: kristinu
2 Replies

3. Shell Programming and Scripting

extensions- simple question

hi guys i have this script Doc_=/home/$USER/Documentos/*.odt || .doc but in the code above, only .odt files are selected, all .doc none. What is the error in the code? thanks (13 Replies)
Discussion started by: felito
13 Replies

4. Shell Programming and Scripting

Ignoring certain extensions

Dear Friends, I want to move all the files to temp folder except files having following extensions which are case sensitive. .ttM .Hmt .dMt Request you to guide me to do the same Thank you in advance Anushree (3 Replies)
Discussion started by: anushree.a
3 Replies

5. Shell Programming and Scripting

Creating multiple extensions

Friends I want to automat sending a letter to different persons whose directories are named as 001, 002, 003, 004. To push the same letter to all these directories, I need to name the letter as letter.001, letter.002 like that. Is there any method whereby I get the extension of this letter... (2 Replies)
Discussion started by: chssastry
2 Replies

6. UNIX for Dummies Questions & Answers

extensions

Hey! Do you guys know of a good site that can explain all the Unix commands... I have been using Unix för almost 6 months but still have probelms with things like -u -U -g -G -R -T bla bla bla bla thanks! Dave (3 Replies)
Discussion started by: inkastinka
3 Replies

7. UNIX for Dummies Questions & Answers

Trying to install FP extensions

Hiya all, (Ops sorry - wrong area in 1st post!) I'm getting the error: Cannot find Apache apxs at /usr/sbin/apxs ERROR: Unable to install mod_frontpage dso (Full error below) (I've tried downloading from both www.rtr.com and www.microsoft... - same error) Please advise! ... (0 Replies)
Discussion started by: marty 600
0 Replies

8. UNIX for Dummies Questions & Answers

.gz extensions

What do I use to open a file with a .gz extension? I'm guessing I need some kind of "unzipping" tool. (1 Reply)
Discussion started by: flopper
1 Replies

9. Shell Programming and Scripting

File name extensions

Hello people, I was wondering if anyone could help me? I want to produce a shell script that changes the filename extension on all matching file. E.G. change all files called ‘something.rtf' to ‘something.doc' by giving the command: Changex rtf doc *where ‘Changex' is the name of... (2 Replies)
Discussion started by: thurrock
2 Replies

10. UNIX for Dummies Questions & Answers

Frontpage extensions

Hi everyone. I'm trying to install Frontpage extensions capacity on my web server and getting this error: ./fp_install.sh: line 59: 6763 Segmentation fault /usr/local/frontpage/version${VERSION}/bin/fpsrvadm.exe -o install -p $port $web $config -u $admin $server $chown -m "" ERROR: /... (6 Replies)
Discussion started by: alwayslearningunix
6 Replies
Login or Register to Ask a Question