OpenSUSE :: How I Can Make Variable Names Out Of String

Jul 13, 2011

I am bad with bash programming and I need some help how I can make variable names out of a string.I will need some help start doing that. And I think the first would be to get part of the filenames strings into variables.

View 7 Replies


ADVERTISEMENT

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 :: Php And Variable Class Names?

Sep 30, 2010

How can I handle the situation below so that the "Fatal Error" message is not shown. It would be ideal if I could supply a default class to be used. I'd prefer to not use: ini_set() to supress the errors but actually be able to "handle" the error.

Code:
<?php
class MyClass

[code]....

View 2 Replies View Related

General :: Concatenate Variable Names In Bash?

Apr 7, 2011

In my script, and I would like to concatenate 2 variables names, to give me the true variable.I've 3 variables X1, X2 and X3, and I invoked them inside a for loop.

Code:
#!/bin/bash
X1=HELLO

[code]....

View 4 Replies View Related

Software :: Environment Variable Names Containing Odd Characters?

Mar 27, 2010

I want to have an environment variable name (not value) containing ':', such as X:X=PQR. There seems to be no reason in principle why not. According to this:[URL].. the only printable character you can't have is '='. And indeed I can set and get such variables with a C program:

#include <stdio.h>
main()
{
setenv("X:X", "PQR", 1);
printf("%s
", getenv("X:X"));

[Code]..

and I can't find a quoting mechanism to make this work. Is there a unix guru out there who knows how to do this in bash, or any other linux shell?

View 5 Replies View Related

Programming :: Bash - Dynamiquely Evaluating Variable Names

May 23, 2011

I'll try to be clear but I think I'm in a mess with my code right now, so it may appear here too

Here is a function. The part I want you to see is the 'eval' sentence.

This works.

It evaluates ${SourceTxt} (which is $1), takes away a part of it and uses it as an array to put data in.

That's alright.

Code:

Now, later, I NEED to count the number of elements in the array(s).

So, I try to do something like....

Which gives me the evaluated name ('#txtFields_email_customers[@]' e.g)

Or

Which gives me nothing....

I was wondering if I was reaching the limits of bash in this kind of capabilities, or if there is a.... bash-like solution. I.e. a good solution

View 7 Replies View Related

General :: Getting Sub-string In A Variable

Jul 13, 2010

I'm facing problems in developing the script as there are errors that sometimes i dun have any idea on how to solve it.What i'm doing now is not homework, but i had been assigned to develop some system in linux.

My problem currently is on sub-string matter, where i need to read the line from file/directory and based on the line retrieved,i need to seperate the information in the line and assign as variable..

Below are my script:

Thus, the output something like this: file_name successfully ran on Mon Jul 12 23:15:00 SST 2009.

Now, what i need to do is to extract certain information from that line which is the name, date, time and the status

The desired output is:

So,my next step is to identify the sub-string and assigned as variable first in order to parse the info and output it.

Thus,my script is:

But i received error message which is:

View 14 Replies View Related

Ubuntu :: Change String Variable In Awk?

Nov 26, 2010

How to change string variable in awk? for example, I parse with awk script text file named some_name_with_extension.txt

I want to print only some_name in my script

Code:
....
varCompName = FILENAME
print varCompName

How to put not all symbols from FILENAME to variable?

This make my day

In windows I used some of next

Code:
%my_var:~0,-2%

would extract all but the last 2 characters of the my_var variable.

View 2 Replies View Related

General :: Awk - Convert Variable To String?

Nov 15, 2010

How do i convert variable to string?

For example:

So how do i make the code with variable work?

View 7 Replies View Related

Programming :: Change String Variable In Awk?

Nov 26, 2010

How to change string variable in awk? for example, I parse with awk script text file named some_name_with_extension.txt

I want to print only some_name in my script

Code:
....
varCompName = FILENAME
print varCompName

How to put not all symbols from FILENAME to variable?

[Code].....

View 3 Replies View Related

Programming :: Bash Concatenating String To Variable ?

Jan 18, 2011

I have a program that loops over each word in a sentence. I need to append a constant to the beginning and end of each word. It works up until the last word on the line.

Code:

Output:

View 4 Replies View Related

Programming :: BASH - If Variable -eq String Not Working ?

Jan 24, 2010

Here is the code:

Code:

How ever when I run this script I get the following error

Quote:

I just don't get it, I have racked my brain trying to figure out every combination of how I should write this if statement and I can't get it to work.

View 2 Replies View Related

Programming :: Pass A Path As A String To A Variable?

Apr 17, 2009

I'm trying to pass a path as a string to an array, but its evaluating it as a command instead. I want to take the literal string "/mnt/accounts/user/temp/*.jpg" and assign it to an array{1}, but when i echo the array variable, it displays it as

pic1.jpg
pic2.jpg
pic3.jpg

[code]....

I just want it to be the actual text "/mnt/accounts/user/temp/*.jpg" which i will be combining with other text to create a longer path elsewhere in the code.

View 5 Replies View Related

Programming :: HOSTNAME Variable Is Being An Empty String

May 19, 2011

The script produces 2 empty lines and I don't know why.

View 1 Replies View Related

General :: Environmental Variable In Bash Command String?

Feb 9, 2011

I do this:

Code:

a@b:~$ export A=hi
a@b:~$ echo $A
hi
a@b:~$ bash -c "export A=blah; echo $A"
hi
a@b:~$

Why doesn't the bash command print the new value of $A? Is there a way to make it do so?

View 6 Replies View Related

General :: Pull String From A File Into A Variable Using Bash

Aug 6, 2011

I have a file (.tmpfile) and inside it is a string which i only know part of, the rest being a random group of characters... I would like to know how to pull the whole string out of the file and into a variable.

View 13 Replies View Related

General :: Special Character In String Variable And Grep

Apr 11, 2011

I want to match some filename in some text, but the filenames I have no control of, so "[" can "]" can appear in the filenames.so do I always have to use sed to addslashes to these variables before I have to grep them? and what other characters have I missed other than "[", "]", "."?

View 4 Replies View Related

Programming :: Append Variable String In A Specific Line?

Jun 8, 2010

I want to append a variable string to the end of a specific line. not like append the same string to each line. like in my file i have 4 columns, i want to add a string in 5th column in some fixed row.

View 4 Replies View Related

Programming :: Bash Thinks String Variable Is A Numeric One

Jul 7, 2011

Bash 3.1.7

Code:

Code:

Code:

I think read A1 A2 makes A1, A2 string variables. Then, when A2 gets the value 01, '01' should be a string. But for some reason bash takes it as numeric. I know there are no types in bash.

View 11 Replies View Related

Programming :: Include A String Variable In A Regex (Perl)

Jan 9, 2010

how do you include a string variable as part of a regex in Perl?

View 5 Replies View Related

General :: Bash: Substitute Parameter In A Quoted String - Stored In Another Variable

Jan 31, 2010

(variable substitution?)
(parameter expansion?)
Code:
run_repeatedly()
{
NUM=0
while [ <irrelevant stuff here> ]
[Code]....

run_repeatedly "programX -o "./messy/path/output-$NUM.txt"" The echo inside the loop prints "...-$NUM.txt"; obviously I'm aiming to have bash substitute the iteration number so that I end up with many output files not 1.

View 5 Replies View Related

General :: Sed/awk/grep Search For Number String Of Variable Length In Text File?

Jan 19, 2010

I need to search a text file for a string of numbers which are different lengths, and always are between number=" and " like:

number="1234567890"
number="22390"

I need to grab those numbers and pipe each one to a line in a file. I've already tried something with awk and that didn't seem to work.

View 10 Replies View Related

Programming :: Copy String A To String B And Change String B With Toupper() And Count The Chars?

Oct 22, 2010

copy string a to string b and change string b with toupper() and count the chars

View 3 Replies View Related

Programming :: Variable String File Base - Output File Doest Not Exclude The Values In Grep -av

May 1, 2011

My script.

This is may script:

Code:

Problem: Output file doest not exclude the values in grep -av

View 3 Replies View Related

General :: Rsync On Windows To Make It Keep Special Characters In File-names

Sep 2, 2010

We're in the process of implementing an offsite backup of all our servers to a remote Linux server. We're using rsync over ssh.What I've found is that characters such as ±, ¶,´ and £ are replaced on the Linux server with underscores.I don't mind if it changes these characters in the filenames of documents, but when it renames a language pack from Espa±ol.clx to Espa_ol.clx, it could cause issues for us further down the line.

What do I need to do differently to make the special characters copy over correctly? For the initial sync which will take place locally, before the machine is moved offsite, I have SAMBA enabled. I am able to copy files from Windows to the Samba share, retaining the original filename, though it looks different in the Linux directory listing, i.e. t̻st becomes ĻstThese files get deleted by rsync when it runs, as it does not match the filenames.

View 1 Replies View Related

General :: Recursively Rename Files/folders To Make Their Names Windows-friendly?

Jan 29, 2011

I have a bunch of files on a Ubuntu box, which have various characters in their filenames that Windows doesn't accept (mostly ":" and "*", but possibly others).What's the simplest way to get these all renamed and moved to a Windows machine? It's OK to replace these characters with something like "[colon]" and "[asterisk]".

View 1 Replies View Related

Fedora :: F13 - Make Location/address Bar In Nautilus Look Like A String?

May 31, 2010

In Fedora 12/11 there used to be a button in the Nautilus to the left of the address/location bar which would let me switch between two representation of location bar: 1) buttons 2) as string that I can type in.

In Fedora 13 I cannot get the same behaviour. The button is missing and location only shows up as a set of buttons.

I have looked in the settings of Nautilus, but couldn't find anything related to this. How do I get location bar to show up as a string where I can manually type the path?

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

General :: Make An Environmental Variable RPMS?

Apr 1, 2011

I'm trying to make an environmental variable RPMS that will resolve to a website. I know I have to make the changes in .bash_profile, but all the things I try don't seem to want to work.

I've tried:
PATH=$RPMS:ftp://rha-server/pub/os/rhel5/Server/
or simply just making the variable itself
$RPMS=ftp://rha-server/pub/os/rhel5/Server/

The second one made a variable just fine, but when I attempted to run this command:

rpm -ihv $RPMS/caching-nameserver*

View 5 Replies View Related

General :: Make A Variable = Filename Without The Extension?

Apr 23, 2011

I am trying to strip the .wav file extension from a file name so that I can pass the result to lame encoder. I started to write a BASH script that looks like this:

Code:

for f in /home/user/wavfiles*; do FILE=basename $f .wav; lame $FILE; done

It doesn't work very well though. For the life of me I can't seem to discover how to use basename in a suitable way for a script like this.

View 8 Replies View Related







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