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.
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
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.
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.
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:
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.
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.
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.
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.
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 "[", "]", "."?
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.
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.
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.
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.
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]".
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?
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:
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.