Sponsored Content
Top Forums Shell Programming and Scripting Variable with several values and spaces. Post 302497586 by spoovy on Thursday 17th of February 2011 03:52:21 PM
Old 02-17-2011
Variable with several values and spaces.

Hello all. I am a newb obviously and a bit stumped on this, so any help gratefully accepted.

The script is extracting metadata from individual mp3 files, then (hopefully will be) sorting them into newly-created subdirectories. I have filtered out the relevant metadata and have the album names listed in a temporary file, one entry per line, like this -

Code:
"Elvis Presley"
"Elvis Presley"
"Pot Luck with Elvis"
"Kid Galahad And Girls! Girls! Girls! (Elvis Double Features) [REMST]"

So what I am trying to do from here is create a directory for each line.
So far I have this-

Code:
#make a new subdirectory for each album
for VARIA in $ALBUMNAMES ;
do
  mkdir $2/$VARIA
done

which splits everything by individual word like this -

Code:
drwxr-xr-x 2 root root 4096 Feb 17 20:49 (Elvis
drwxr-xr-x 2 root root 4096 Feb 17 20:49 And
drwxr-xr-x 2 root root 4096 Feb 17 20:49 Double
drwxr-xr-x 2 root root 4096 Feb 17 20:49 Elvis
drwxr-xr-x 2 root root 4096 Feb 17 20:49 Features)
drwxr-xr-x 2 root root 4096 Feb 17 20:49 Galahad
drwxr-xr-x 2 root root 4096 Feb 17 20:49 Girls!
drwxr-xr-x 2 root root 4096 Feb 17 20:49 Kid
drwxr-xr-x 2 root root 4096 Feb 17 20:49 Luck
drwxr-xr-x 2 root root 4096 Feb 17 20:49 Pot
drwxr-xr-x 2 root root 4096 Feb 17 20:49 Presley
drwxr-xr-x 2 root root 4096 Feb 17 20:49 [REMST]
-rw-r--r-- 1 root root  692 Feb 17 20:49 initial_output
drwxr-xr-x 2 root root 4096 Feb 17 20:49 with

..which is obviously not what I want. How can I get the for loop to run once for each line of input rather than once for each word?

Thanks in advance

spoov
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strip leading and trailing spaces only in a shell variable with embedded spaces

I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help. echo $SH_VAR | command_line Syntax. The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies

2. Shell Programming and Scripting

Replace spaces with 0's having numeric values.

What could be the regular expression with gsub function in awk to replace all numerics having spaces before to be replaced with 0s? (1 Reply)
Discussion started by: videsh77
1 Replies

3. Shell Programming and Scripting

Variable containing spaces

Hi, my var is: PATH_LOG=/opt/WebSphere/CR Comune Roma.log a filename which contains blank chars. How can I call it from prompt ? Ex: ls $PATH_LOG or cat $PATH_LOG tks, Carmen- (2 Replies)
Discussion started by: Carmen123
2 Replies

4. Shell Programming and Scripting

adding spaces for a variable value

Hi, i have to form the header and add fillers(spaces) to it. I have done something like this. i have added 10 spaces at the end HDR="AAAABBBBCCNN " echo $HDR >> file1.dat but the spaces are not being stored in the file. How to add the spaces. (2 Replies)
Discussion started by: dnat
2 Replies

5. Shell Programming and Scripting

Reading variable from file variable values

Hi, Here is the output of lpstat. I would like to read value of Queue which is(abxxxxb1)and status that is DOWN in first line. i dont care what is in second line. any one can help me.thanks Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- ---------... (5 Replies)
Discussion started by: sagii
5 Replies

6. Shell Programming and Scripting

How to find spaces and update values on the same line.

Dear all, I'm trying to write a script where: A file contains more or less 2000 lines. To some of those lines, in a specific position, let's say 89-92 there are spaces. So, this script should find these spaces on specific position and update a value (from 2 to 1) to another position of the... (4 Replies)
Discussion started by: paniklas
4 Replies

7. UNIX for Dummies Questions & Answers

Get all values separated with spaces(solved)

Hi, i have this text: X (m) 4917536.9627 4917536.9673 0.0090 -0.0046 Y (m) -815726.1383 -815726.1294 0.0061 -0.0089 Z (m) 3965857.4730 3965857.4840 0.0071 -0.0110 X (m) 4917536.9627 4917537.1411 -0.1784 0.1710 Y (m) -815726.1383 -815726.4859 0.3476 0.3489 Z (m) 3965857.4730... (2 Replies)
Discussion started by: limadario
2 Replies

8. Shell Programming and Scripting

csh and variable values with spaces

my working shell is csh and even though if I try to run my script in plain sh, it behaves the same way. Here's a simple script: #!/bin/sh desc='"test my changes"' cmd="echo \"$desc\"" $cmd I want $desc to be passed as an argument to another command, but csh apparently doesn't like spaces in... (5 Replies)
Discussion started by: iskatel
5 Replies

9. AIX

How to append spaces to string values?

i/o file: abc,efg,xyz Required o/p file: "abc (Value + blank spaces=16) " ,"efg (Value +blank spaces=15) " ,"xyz (Value+ blank spaces =20) " In short input file value stores in result file with " i/p Value " added with spaces and are of fixed size like 16,15,20 How to do using... (2 Replies)
Discussion started by: AhmedLakadkutta
2 Replies

10. Shell Programming and Scripting

Shell command to convert low values to spaces

I neead a script which converts low values to the spaces, When I used sed -e 's/\x00/\x20/g' inputfile command it is removing the low values but not replacing it with spaces. Please help me. Its Uregent. Thanks Sam (12 Replies)
Discussion started by: bsreee35
12 Replies
dsenableroot(8) 					    BSD System Manager's Manual 					   dsenableroot(8)

NAME
dsenableroot -- enables or disables the root account. SYNOPSIS
dsenableroot [-d] [-u username] [-p password] [-r rootPassword] DESCRIPTION
dsenableroot sets the password for the root account if enabling the root user account. Otherwise, if disable [-d] is chosen, the root account passwords are removed and the root user is disabled. A list of flags and their descriptions: -u username Username of a user that has administrative privileges on this computer. -p password Password to use in conjunction with the specified username. If this is not specified, you will be prompted for entry. -r rootPassword Password to be used for the root account. If this is not specified for enabling, you will be prompted for entry. EXAMPLES
-dsenableroot Your username will be used and you will be queried for both your password and the new root password to be set to enable the root account. -dsenableroot -d Your username will be used and you will be queried for only your password to disable the root account. -dsenableroot -u username -p userpassword -r rootpassword The supplied arguments will be used to enable the root account. -dsenableroot -d -u username -p userpassword The supplied arguments will be used to disable the root account. Mac OS August 08 2003 Mac OS
All times are GMT -4. The time now is 05:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy