how to write script to create directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to write script to create directory
# 1  
Old 03-27-2008
how to write script to create directory

Please help. I am the beginner. Don't understand about archive file. How to create a directory for the files from each archive with name of directory which equivalent to the base name of the archive. eg I have file abc.txt. How can I create a directory name abc. Thank you
# 2  
Old 03-03-2009
Use basename

Hi Snail,

This is quite easy in Unix, just use "basename" command.

# basename abc.txt .txt

will give you the base name of the abc.txt.

# mkdir `basename abc.txt .txt`

will do pretty much what you want.

# man basename

also helps Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. Shell Programming and Scripting

Need to write a script that checks whether files are moving out of a directory.

I have a directory that has files going into it and moving out on a regular basis. The normal state of the directory would be to be empty. I need to write a script that will check to see if files are Not moving out of the directory. Any help would be most welcome. (4 Replies)
Discussion started by: RoBKoS
4 Replies

3. Shell Programming and Scripting

Perl script to create/write into spreadsheet

Hi, I need help in debug following script. can somebody help....!!! #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; # Create a new workbook called simple.xls and add a worksheet. my $workbook = Spreadsheet::WriteExcel->new('simple.xls'); my $worksheet =... (1 Reply)
Discussion started by: chettyravi
1 Replies

4. Homework & Coursework Questions

Create script to add user and create directory

first off let me introduce myself. My name is Eric and I am new to linux, I am taking an advanced linux administration class and we are tasked with creating a script to add new users that anyone can run, has to check for the existence of a directory. if the directory does not exist then it has... (12 Replies)
Discussion started by: pbhound
12 Replies

5. Shell Programming and Scripting

how to create and access a directory in the same script using variables

I have a working script that defines the paths using variables which is used to move a rename files that are being archived. Is there a way to create a directory in the path with the date as the name and then reference it when moving the file to it? Here is what I have tried with no luck.... ... (1 Reply)
Discussion started by: Snickyt0310
1 Replies

6. Shell Programming and Scripting

How to write a directory lock shell script?

Hi there, pleas I want this script urgently. how to lock a directory by shell script? (12 Replies)
Discussion started by: joneggk
12 Replies

7. UNIX for Dummies Questions & Answers

Create a shell script for write files with 2 parameters

Hello, I'm a newbie in shell script. So, i would like to create a shell script which take 2 IN parameters (PARAM1 and PARAM2). This script need to create 2 files as : I need to create this file /etc/apache2/sites-available/PARAM2 : <VirtualHost *:80> DocumentRoot "/home/PARAM1/www"... (0 Replies)
Discussion started by: chatlumo
0 Replies

8. Shell Programming and Scripting

To write a shell script which groups files with certain pattern, create a tar and zip

Hi Guru's, I have to write a shell script which groups file names based upon the certain matching string pattern, then creates the Tar file for that particular group of files and then zips the Tar file created for the respective group of files. For example, In the given directory these files... (3 Replies)
Discussion started by: rahu_sg
3 Replies

9. Shell Programming and Scripting

create a new directory from cgi script

hello. i hav accepted name of directory from user through a form.now i need to create a directory under cgi-bin of that name.I am not able to do so.n help is required (12 Replies)
Discussion started by: raksha.s
12 Replies

10. UNIX for Advanced & Expert Users

how i write script to create 30 processes

helo i make one process for com port . in that i create two thread one for reading data and another for writing data to com port. now i want to write a script which create 30 processes for handling 30 com port. is it good solution for handling 30 com port. Thx & Regards, Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies
Login or Register to Ask a Question