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


ADVERTISEMENT

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 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

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

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 :: 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

Programming :: Make Bash Replace The Value Of A Variable?

Apr 18, 2009

I have a program I am writing where I have a for loop and I want to make it substitute the variable twice like:

for ((i=0;i<5;i++)) do
echo $"$i"
done

[code]...

View 3 Replies View Related

Programming :: Make Variable To Refer A File In A Folder?

Dec 16, 2008

How can i make a variable in a bash script, to refer each file in a folder,and to switch it to the next file,until the last file of the folder?

View 2 Replies View Related

Programming :: Make Radiolist Dialog Which Content So Many Options What Is The Value Of The Variable?

Dec 14, 2010

How can I make radiolist dialog which content so many options what is the value of the variable?Quote:

echo "How many options?"
read=VAR
dialog --title "sdf" --backtitle "sdff" --radiolist "ffdsfsd" 15 60 5 "1" "first" on "2" "second" off "3" "third" off "4" "fourth" off etc..

I must explode dialog in loop and add options? or something like that?

View 2 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 :: 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

General :: Assign Local Variable Values To Global Variable?

Feb 17, 2011

how to assign a local variable value to a global variable....

View 2 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

General :: Create An Environment Variable With The PRINTER Variable?

Apr 16, 2011

I am supposed to create an environment variable with the PRINTER variable, which should resolve to the word sales. Would the command be like this?: env PRINTER - NAME=SALES (is this the command to create that variable with resolving the word sales to it?)

View 3 Replies View Related

Software :: Get Variable From Text File Into Bash Variable?

Jun 10, 2009

I have a text file i that has a mailTo: NAME in it. In a bash script i need to extract NAME and put it in a $variable to use. How do i do this?

View 2 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

Programming :: Can't Use Dollar Sign In String

Jul 17, 2011

i have a bunch of ubnt nanostations M series (wireless access points/routers)... they use airOS (a fork of openwrt). it runs a custom firmware that i made using provided sdk. and the lighttpd uses php/fi 2.0.1.... this is (of course) used to serve the web configuration.the problem: i need to use the ($) in a string but i couldn't. what i need to do is download some file from the internet using wget and have the pid of wget back to keep track of the process, then parse the output to the page.

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







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