• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

for i ... strip filename and make dir

Hi,

I have to dirs:

dir1/
dir2/

In dir1 there are a lot of filexxxxxx.tar.gz files

when I do a "for i ..." and $i contains everytime one path+filename for example: /full/path/filename30.tar.gz
I need to make in dir for each file a directory, for example mkdir filename30.

Best regards,

Harry
0
harryv
Asked:
harryv
1 Solution
 
TintinCommented:
It would have been useful to show the actual loop you are using.

Anyway, to make a directory from the full filename, do:

mkdir `basename $i | sed "s/\..*//"`
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now