LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-06-2008, 04:02 AM   #16
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983

Please, post the exact command line you've used along with the assignments of BASENAME, STARTDIR, ENDDIR. On my system it works fine:
Code:
$ BASENAME=test
$ STARTDIR=1
$ ENDDIR=12
$ mkdir $BASENAME$(seq -w -s " $BASENAME" $STARTDIR $ENDDIR)
$ ls
test01  test02  test03  test04  test05  test06
test07  test08  test09  test10  test11  test12

Last edited by colucix; 07-06-2008 at 04:10 AM.
 
Old 07-06-2008, 07:41 AM   #17
Count Zero
Member
 
Registered: Feb 2008
Distribution: Debian wheezy
Posts: 130

Original Poster
Rep: Reputation: 15
Hi, this is what I punched in:

Code:
mojoman@jukejoint:~/new$ BASEDIR=test
mojoman@jukejoint:~/new$ STARTDIR=1
mojoman@jukejoint:~/new$ ENDDIR=12
mojoman@jukejoint:~/new$ mkdir $BASENAME$(seq -w -s " $BASENAME" $STARTDIR $ENDDIR)
mojoman@jukejoint:~/new$ ls
01  02  03  04  05  06  07  08  09  10  11  12
mojoman@jukejoint:~/new$
Also:

Code:
mojoman@jukejoint:~/new$ bash --version
GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
mojoman@jukejoint:~/new$
Any ideas on what I'm doing wrong?


Thanks
 
Old 07-06-2008, 08:01 AM   #18
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.

In many cases, nounset is a good friend:
Code:
#!/bin/bash3 -

# @(#) user3    Demonstrate use of nounset.

echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1)
echo

set -o nounset

BASEDIR=test
STARTDIR=1
ENDDIR=12
echo $BASENAME$(seq -w -s " $BASENAME" $STARTDIR $ENDDIR)

exit 0
Producing:
Code:
% ./user3
(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash 3.00.16(1)-release

./user3: line 14: BASENAME: unbound variable
cheers, makyo
 
Old 07-06-2008, 08:04 AM   #19
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
./user3: line 14: BASENAME: unbound variable
Yes. Count Zero, you assigned BASEDIR then used BASENAME.
 
Old 07-06-2008, 08:34 AM   #20
Count Zero
Member
 
Registered: Feb 2008
Distribution: Debian wheezy
Posts: 130

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by colucix View Post
Code:
./user3: line 14: BASENAME: unbound variable
Yes. Count Zero, you assigned BASEDIR then used BASENAME.
Arghh! (slams forehead really hard into keyboard)

Thanks! That was it. I don't know how I missed it. I appreciate you giving your time, effort and expertise.

I'll also be using the nounset option in the future...

Cheers!
 
  


Reply

Tags
bash, create, directories, multiple


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script to create sequential, numbered directories ericcarlson Linux - Software 4 01-08-2010 09:43 AM
Change text in multiple files in multiple directories vivo2341 Linux - General 5 11-27-2006 08:16 PM
Script to create multiple directories under users homes shawnbishop Linux - Software 4 03-30-2006 08:11 AM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 12:23 PM
BASH scripting browsing multiple directories PokerFace Programming 3 10-02-2002 12:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration