• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • 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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

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