Programming :: Read A Foldername Into A Variable?

Jul 14, 2010

I am trying to write a script which can read the names of all folders within a given folder into separate variables. In effect, if a folder contains a folder "Folder1", "Folder2", "Folder3", the script would read those names into variables such as:

Variable1 = "Folder1"
Variable2 = "Folder2"
Variable3 = "Folder3"

I have tried fiddling with the find . command, but without any success.

View 3 Replies


ADVERTISEMENT

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Programming :: Read A Config Variable Into A Script?

Jun 8, 2010

What's the best way to read a value from a configuration file into a script?I'm trying to get the command_file vaule from nagios.cfg into a script, this works but what's the best way to do it?

Code:

command_file=$(perl -F= -lane 'print $F[1] if /^[[:space:]]*command_file[[:space:]]*=/' /etc/nagios/nagios.cfg)

View 5 Replies View Related

Programming :: Looping Using While Read Line And A Variable Instead Of A File?

Sep 24, 2010

I created the following.

x="top
middle
bottom"

I would like to make the following work.

while read line
do
echo $line
done

instead of importing a file I would like to use the variable $x I tried using pipes, but with no luck. My goal is to read one line at a time, but not have to export my data to another file, I would like to keep it all within one script.

View 3 Replies View Related

Programming :: Bash Scripting...read A Value From A File Then Assign To Variable?

Feb 27, 2011

At my wit's end I can't find anything that I understand well enough to use. This is for a Unix class, we are working with shell scripting. File1 has 5 in it and File2 has 100 in it.The teacher wants us to read the values then do the math. This is what I have so far:#!/bin/bashvar1='cat File1'var2='cat File2'var3=`echo "scale=4; $var1 / $var2" | bc`echo The final result is: $var3

View 9 Replies View Related

Programming :: Make A New Variable With The String From The Old Variable Btut Without Any Plus Sign?

Apr 7, 2010

my script has a variable which comes in the form +00.00 +0.00 -00.00 or -0.00 (the numbers can be any in that form) for any that have a + symbol I need to remove the +, but if it has a - symbol it needs to stay.

i need to make a new variable with the string from the old variable btut without any plus sign. I have tried a lot of different ways with no success, each thing I tried either left the + or removed the entire string. I think this should work but doesn't

foo=+12.40
bar=${foo#+}

View 4 Replies View Related

Programming :: Search Within A Variable And Assign The Results To A New Variable?

Apr 25, 2011

how I can search within a variable and assign the results to a new variable. I'll use the following as an example -

cars="Audi BMW Cadillac Chevy Dodge Ferrari Ford Mercedes"
list=`echo ${cars} | egrep -o '<A?+|<C+'`

with the echo command I get the following output assigned to list -

A
C
C

What I'd like to get for output is -

Audi
Cadillac
Chevy

how I could do this regardless of upper/lower case letters?

View 5 Replies View Related

Programming :: Assign Value Of C Variable To Shell Variable?

Apr 28, 2010

included shell script inside c program, and i wanted to assign the value of c variable to shell variable..Can any one please suggest me how to do it?

View 8 Replies View Related

Programming :: Assignment To A Variable Variable?

Mar 17, 2011

This loop is part of a bash script which takes multiple arguments.

Code:
for ((i=1;i<=$number;++i)) ; do
offset=$(($i+5))

[code]...

View 3 Replies View Related

Ubuntu :: How To Make Variable And Read From Second Terminal

Apr 27, 2011

I have two terminals open and I want to save the current path in a variable and read it from the second terminal that I have open.

Then in the first terminal I type:
Code:
A=$(pwd)
And in the second I type:
Code:
echo $A
that doesn't work though.

I have tried also with
Code:
export A=$(pwd)
and
Code:
alias A=$(pwd)
but nothing seems to work. Is there a way to do this?

View 4 Replies View Related

Slackware :: Bash: HISTTIMEFORMAT: Read Only Variable

Nov 11, 2010

I have a problem when i ried run this command (export HISTTIMEFORMAT="%F %T ") on slackware 13.0. the answer is the following (-bash: HISTTIMEFORMAT: readonly variable) I am running this command on the bash like root.

View 2 Replies View Related

Ubuntu :: Read A Variable From File (bash Script)?

Nov 8, 2010

I googled and tried to find an easy step by step-by-step guide on how to use a bash script read a variable from a file. This is the way I did it (but it does not really work so something is wrong, but what?) (testfil2 contains one line that readsidnumber=1578

#!/bin/bash
value="/home/user1/Desktop/testfil2"
echo $value
kill $pidnumber

View 4 Replies View Related

General :: Copy Files To /usr/share/foldername With Gnome?

Jul 19, 2011

I had to copy some files from terminal to a folder in /usr/share/foldername so I did sudo cp -r something/ /usr/share/foldername which worked, but when I wanted to do it in Gnome, it kept saying I have no permission. How do I do it so it asks for permission, or how do I do sudo + task in Gnome ?

View 6 Replies View Related

General :: Executing Binaries - Pass The Hostname As A Variable Or Read From A File?

May 2, 2010

I am looking for a clue in shell or ant script, where I excecute a binay file on linux. For example ./myfile.bin which ask me few questions.

./myfile.bin ...........................100%

I would like to automate this process where I want to pass the hostname as a variable or read from a file is it possible? If yes any sample`s on this. I can do if this was a shell script ($1) but not sure when its binary.

View 8 Replies View Related

Networking :: Samba Shares On Server - Nagging File / Foldername

Aug 17, 2010

This one has proven to be a real for me. On one of my Samba shares on my server I have a folder of mp3 files of my CDs. The one I am having an issue with is "Clarence Carter/Dr. C.C." (yes, the one with the ULTIMATE party song). The "Dr. C.C." folder name is normal locally, but across Samba it comes out "DMOU3A~H". I can still access the folder this way, but it would be nice to not have Samba mangle the folder name this way. I am using Samba 3.4.2 on an Athlon64 X2 system running Slackware64.

View 2 Replies View Related

Programming :: Pass Variable In Mysql Qyery In C Programming?

Dec 4, 2010

i want to pass variable in mysql qyery in c programming

View 1 Replies View Related

Programming :: Timer In Socket Programming - Wait For X Sec After Read() And Then Disconnect The Client Connection

Mar 8, 2011

I have a server listening on incoming client connections. Once the client establishes SSL connection with the server, the server waits on read() from the client. Only Client can disconnect the connection. I want to have a timer in the server program to wait for x secs after read() and then disconnect the Client connection.

View 3 Replies View Related

Programming :: Sed A Variable In Bash?

Mar 25, 2011

I have beat this enough and don't get what should have been a very simple thing to do. I build a variable;

Code:
CLIST=java,lua,python,php,perl,ruby,tcl
CLIST will be used by another bash script but I need to replace the commas with a space. I

[code]...

View 2 Replies View Related

Programming :: C++ Get Variable Name From Document Name?

Apr 9, 2010

How would I go about defining a variable from a document name. Example:document01.doc I want to take the 01 and set X to equal integer 1.

View 1 Replies View Related

Programming :: Defining Variable With Sed?

Jun 2, 2010

I need to replace JAVA_OPTS= with JAVA_OPTS=<some_value>.I need to give "" value at the end of the replacement. I have tried with the following but it is not working: sed -e "s|JAVA_OPTS= |JAVA_OPTS=<some_value>"

View 2 Replies View Related

Programming :: Can Awk Take A Shell Variable

Jul 23, 2010

I have been searching most of today and am stuck on getting a variable into an awk portion of my bash script. I have this working:

Code:

#!/bin/sh
SRC=/var/log/mail.log
DEST=/var/www/output/myFile.txt
VAR=userName@myDomain.tld

[code]....

Can awk take a shell variable? Or do I have to do something completely different?

View 11 Replies View Related

Programming :: C++ Variable Type Followed By *?

Jul 1, 2010

In C++ what does the suffix, "*" mean appended to a variable type, e.g., "char* variable1;"?

View 3 Replies View Related

Programming :: Initializing A Variable In C?

Nov 5, 2010

Following is the way I saw a variable initialized in C

Code:

static const unsigned int rtl8139_rx_config =
RxCfgRcv64K |
(RX_FIFO_THRESH << RxCfgFIFOShift) |
(RX_DMA_BURST << RxCfgDMAShift);

on following link

[URL]

I have initialized variables in past but above initialization I could not understand what is it?

View 4 Replies View Related

Programming :: Print Variable Value In Awk?

May 16, 2011

problem statement:

pattern_search="Exam Name"
sed -n "/$pattern_search/,/hello/"p tmp5 | awk '{if ( $4 != 0 && $4 ~ /[0-9]+.*[0-9]*/ ) print "$pattern_search" " " $0 }'

"tmp5" is a file. this is printing output as

$pattern_search value1

i.e value of $pattern_search is not getting substituted. i am expecting output as

Exam Name value1

View 3 Replies View Related

Programming :: Retrieving Value From Variable

Feb 5, 2010

how shall I print each variable separately using a generalized form. I tried writing the following within a for loop...Code:echo $(echo a$(echo $i)$(echo $j))which did yield no result. So what shall I write??

View 3 Replies View Related

Programming :: Release Value Of Variable In Awk?

Mar 8, 2011

I have the following input:

Code:

Event 1............................................................
full_name: JENNY_JENNINGS genre: f
age: 32

[code]....

But as you can see in the input, in the 2nd "Event", the line containing "age" is not present, but in the output my code is printing the 1rst age value twice. The correct output should be blank in the age field for 2nd line in the output like this:

Code:

full_name|genre|age|code
JENNY_JENNINGS|f|32|15a
JOHN_JOHNSON|m||23c
MARY_JEAN|f|25|11d

What is wrong in my code? how can I fix it? * I�m using ubuntu 10.10

View 12 Replies View Related

Programming :: Set Environment Variable Is Tcl ?

Apr 22, 2011

How are environment variable set in tcl? I tried "set $env(MYVAR) xxxx" but it didn't work.

View 1 Replies View Related

Programming :: Using Variable In A Command?

Apr 14, 2011

i'm trying to execute a shell script, i'm trying to use the values in an array for use in a sed command:

sed -n '/Sales ID: ${array[$i]}/,/Totals:/p'

that command creates empty files. so my guess is that its not recognizing the array as an array but as text?
how would i be able to utilize the array in the command? i got it, didnt think that if i doubled up the single quotes that it would work, but this worked:

sed -n '/Sales ID: '${array[$i]'}/,/Totals:/p'

View 4 Replies View Related

Programming :: Variable Is Gone At The End Of While Loop?

Mar 25, 2011

I have a directory file capturing script, the variable is fine with in the loop but gone after the loop is done:

Code:
DIR="/usb/sdb1/media/music/"
i=1

[code]...

View 9 Replies View Related

Programming :: Variable Not Incrementing In C

Sep 10, 2010

It compiles fine, but gets stuck in the loop. z never increments. I was using a for loop originally but had the same problem so I decided to try a while loop.

[code]....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved