![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| create folder in windows from unix while FTP | Metalero de Oz | UNIX for Dummies Questions & Answers | 0 | 05-14-2008 01:22 PM |
| Pack current folder | WebWatch | UNIX for Dummies Questions & Answers | 3 | 12-17-2007 05:46 AM |
| AIX - create folder in hdisk1 instead | lwy2020 | AIX | 3 | 01-16-2007 04:56 AM |
| How can I create a file with current time - 60 minutes | DaveyTN | Shell Programming and Scripting | 4 | 10-05-2005 08:17 PM |
| create directory named current date | flowrats | UNIX for Dummies Questions & Answers | 2 | 07-30-2002 11:26 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Use awk to create new folder in current directory
Alright, I am sure this is a laughable question, but I don't know so I am going to ask anyway.
I have a little script I am writing to take information from one source, recode it in a certain way, and print to files for each subject I have data for. This all works perfectly. I just want to put a little icing on the cake if you will and make is so no matter where I run the script, or on what computer, it will always send all of the output to a new folder in the current directory. To be more specific. Lets say I am running the script in /home/research/. Instead of sending the output to the current directory proper, I want to create a new folder to stuff it all in, so it is not intermingled with my other files. I travel a lot, so if I hardcode " > "iat_exp/" et "_" sn ".out", I get an error if the folder iat_exp does not exist yet. So, I want my awk script to create that folder when it starts running. I hope this is enough detail... I am an inexperienced scripter and am just using awk in cygwin on my xp laptop, although I am setting up my first Ubuntu box, so I am pretty excited about that. Thanks all, Chris |
|
||||
|
A better version that sends errors to /dev/null if the directory "iat_exp" already exists. Code:
awk '{"mkdir iat_exp 2>&-" | getline;print stuff}' inputfile > iat_exp/outputfile
|
|
||||
|
One more approch...by calling the system command
Code:
echo $a |awk '{system("mkdir directory");}'
|
| Sponsored Links | ||
|
|