Red Hat / Fedora :: How To Extract Certain Strings From A Variable

Mar 18, 2009

I have one question.

Assumed I have have a variable $userlist, it has the following contents:

brownj
smithk
smithk2
smithk3
hynesp
hynesp2
leeb

How can I write a bash script that extracts all the strings smithk, smithk2, smithk3, etc from variable $userlist, and assigns these strings to a new variable?

View 1 Replies


ADVERTISEMENT

Ubuntu :: Extract Only The Strings After The Comma?

Jun 1, 2010

I have a csv file in this format:

Code:
1,characterswithnospace
2,same
4545,characters
I want to extract only the strings after the comma,

View 4 Replies View Related

General :: Extract Strings Based On Character Positions?

Mar 21, 2010

I have a file with no regular way to grep or sed for any regular expression. The wordings, fields, spacings are random. code...

I want to extract character positions 3 to 10 including spaces. code...

View 8 Replies View Related

Programming :: Variable Strings In A Script?

Sep 5, 2009

I have a set of numbers under some headers in a file:

FNUM,BNUM,C1N,C2N,C3N,C1S,C2S,C3S,
4535, 109, 5.5955, 5.6523, 5.8084, 311.419, 295.2540, 286.9984,
4536, 109, 5.7667, 5.7174, 5.6771, 291.782, 285.0646, 271.5945,

[code]...

View 2 Replies View Related

Programming :: Implement Variable Substitution In Strings?

May 6, 2011

I have an interpteter that supports string literals, and the way it works is that the lexer returns the entire string as a single token, with the quotes removed and escape sequences replaced with the literal characters they represent.

I already implemented single-quote strings, they don't interpret any characters specially except for the single quote. I partially implemented double-quoted strings, they already support all the same backslash escape sequences that C does. But I would also want to add variable substitution.

The way it would work is that "${expression}" would interpret the expression (which could just be a variable name) and replace itself with the result. But I have no idea how to do this.

In case it matters, I'm using a hand-written lexer and recursive-descent parser.

View 14 Replies View Related

Programming :: Bash Variable Parsing / Extract And Put Into Variables Each Combination Of F1 And F2 In A Loop?

Oct 14, 2010

I have a bash variable where the content looks like this where ;f1; and ;f2; are delimiters:
;f1;field1value1;f2;field2 value1 ;f1;field1value2;f2;field2 value2 ;f1;field1value3;f2;field2 value3

So what I need is to extract and put into variables each combination of f1 and f2 in a loop to something like that:

#first pass of the loop I need:
f1=field1value1
f2=field2 value1

#second pass of the loop I need:
f1=field1value2
f2=field2 value2

# third pass of the loop I need:
f1=field1value3
f2=field2 value3

View 15 Replies View Related

General :: Searching And Replacing Strings In File With Strings In Other Files

Jul 29, 2010

I want to search and replace strings in a file with strings in other files/i need to do it with big strings(string1 is big) and i want to use a txt file for this.But this code not working :

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

Fedora :: Where Is 'Extract Here' Option Gone

Jun 12, 2011

Fedora 15 with Gnome 3 is turning out to be dream for me. I am loving it, except few of the old things are gone. I don't care about the not so important stuff but I do care about the Extract here menu option, that I used to have before. I did checked I have latest unrar installed but still I don't see in Nautilus 3.0.2 context menu Extract Here option to unrar compressed files. So, I have to use the Archive manager which I want to avoid. Other feature I am missing is status bar in desktop (bottom bar) any idea how to get that back on gnome 3.

View 7 Replies View Related

Red Hat / Fedora :: Tar - Any Way To Extract Data On Same HD

Oct 6, 2010

I have a host with CentOS 20 GB HD. I want to extract the backup file filename.tar.gz on the host. The file size is 14.9GB and hd is 20. Is there a way to extract the data on the same HD without having to download the file on my local pc and then extract and re-upload.

View 2 Replies View Related

Red Hat / Fedora :: Extract Particular Data?

Nov 30, 2010

Suppose there is a list of files each containing an IP range 192.168.0.1-192.168.0.254 with their their respective downloads and uploads. I can extract the IP with 192.168.0.188 successfully from all the files,but when I want to extract the IP with 192.168.0.7 or like this , grep returned with IPs 192.168.0.7* .How will extract the exact lines having 192.168.0.7

View 1 Replies View Related

Red Hat :: Extract RPM From Fedora 12 On CentOS 5.5

Aug 21, 2010

I have problems to compile vanilla kernel on CentOS, so I downloaded kernel rpm from Fedora 12 that is similar version to extract config file from it. However, standard method

Code:

rpm2cpio file.rpm | cpio -idmv
does not work. It says something like

Code:

cpio: warning: skiped ... lines of junk
cpio: y4: unknown file type
cpio: premature end of file

I tried find answer using Google, but nothing about extraction of this new Fedora rpms on CentOS, only on older Fedora.

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

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

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

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

Red Hat / Fedora :: Extract Files From A .dd File?

Jul 28, 2010

I have a file : cpq_cciss-2.6.20-34.rhel4.i686.dd which is designed to build a floppy disk; these floppy is used to hold disk driver which is not on RedHat CD-Rom. But this .dd is not complete: some files, like /drivers/pci.ids are missing.My idea is to extract all files from .dd file, put missing files and then re-create a new dd file. But, how can extract all files from initial .dd file, and then recreate a new one?

View 8 Replies View Related

Red Hat / Fedora :: How To Extract .part Files

Jul 8, 2011

I'm trying to extract .part files. These are mac extensions similar to .rar or .zip. I need to extract a whole bunch of them simultaneously. Theyre probably registered in sequence just like .rar files. What program can I yum install or where should I look to extract these to what will probably be an ISO.

View 1 Replies View Related

Fedora :: Extract Data From Zip Archive With Password?

Dec 11, 2009

Man I can't extract data from a zip archive with password witch contains ")" and "(" characters...See my treminal:Quote:

[swampyx@AMD-RO-HD ~]$ unzip zplW.zip
Archive: zplW.zip
[zplW.zip] zplW/ password:

[code]...

View 2 Replies View Related

Fedora :: Can't Extract With Unrar / Make This Work?

May 18, 2010

I have a .rar file called Japanese, and every time I enter the command "unrar e Japanese.rar", I get the response "Cannot open Japanese.rar No such file or directory No files to extract".

I've done everything on this site, but I can't get it to extract. What do I have to do to make this work? Do I need to set the directory or something? I've seen other people mention that as a solution for other problems, but have no idea how to do it.

View 6 Replies View Related

Fedora :: How To Extract Line From Text File

Aug 24, 2010

I'm trying to figure this error message out. This little script is supposed to tweet my laptop's IP address, as a cron job, I'm hopeful that it would do so even if it's stolen. This is a variant of one that works, but this doesn't, and I can't see a difference in the curl line of either one.

Code:
#!/bin/bash
user="xxxxxx@xxxxxxxxx"
pass="xxxxxxxxxxx"
wget [URL]
TWEET=`sed -n 1p index.html`
curl --basic --user "$user:$pass" --data-ascii "status=$TWEET" "[URL]"
rm -f index.html
exit
This is the error message.

Code:
curl: (6) Could not resolve host: status=66.183.103.67; Cannot allocate memory
{"request":"/statuses/update.json","error":"Client must provide a 'status' parameter with a value."}
Why does curl think the status is the URL?

View 7 Replies View Related

Fedora :: Extract Specific Files From A .tar Archive?

Jul 20, 2011

I have a .tar archive of music that I would like to extract specific files / folders from. I've been looking at man tar but I don't seem to be able to find any information related to my quest, although someone will likely point out that it's right there in front of my nose

Anyhow, the file is called music_archive.tar and I would like to extract the folder /music/P/Pink Floyd/The Wall/. Anyone know how to do this

View 2 Replies View Related

Software :: How To Extract File *.rar On Fedora Core Ver 13

Jan 22, 2011

I use Fedora Core version 13 on laptop. my friend usually use windows OS, and send to me more *.rar I can't extract file *.rar on FC 13.

If use know, how to install WinRar on FC 13

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

Fedora :: Tool To Extract A Multi-sector Nrg File?

Dec 16, 2009

I have a multi-sector nrg file that I would like extracted. I can't seem to find a way to extract the contents of it! Please tell me if there is a tool I can use to do this!

View 2 Replies View Related

Red Hat / Fedora :: Root Directory - Password To Extract / Copy Any File

Jul 20, 2010

Why do I always need to write "su" then my password to extract or copy any file in fedora 11. How to configure so that I always be in my root directory.

View 3 Replies View Related

Fedora :: Extract Monitor Serial Number / Manufacture Date Using EDID?

Aug 29, 2010

I can not for the life of me determine how to get the monitor serial number / manufacture date using Extended Display Identification Data (EDID). Does anyone know? None of the following provide this info:

monitor-get-edid
monitor-edid --v
monitor-edid --MonitorsDB
monitor-get-edid | monitor-parse-edid
dmidecode -q

View 8 Replies View Related

General :: Use The Value Of One Variable To Generate A Name For Another Variable?

Jul 25, 2010

can i use the value of one variable to generate a name for another variable? for example i want to use the counter from a "do while" loop to name and define a variable each time the loop executes. for example

objectnames1=`ls -a`
objectnames2=`ls -a`
etc.

i don't have a script yet but each time through the loop i intend to cd to a particular directory and then define a variable containing a list of each object in that directory as values. for the rest of the script to work, each variable generated has to be unique, and i can't think of a good way to accomplish this.

if using a value from one variable to name another isn't possible, can anyone think of a more elegant solution? i know limited syntax but i'm willing to read up...

View 6 Replies View Related

General :: Sed Substitution Of Variable With A Variable?

Dec 27, 2010

I am trying to alter the character position of residue numbers above 999 in a pdb file.The following script is an attempt to:1) Get all unique pdb residue numbers (in column 5) using awk and assign it to a variable i.2) Loop through all the values in $i and if it is greater than 999, shift that number one character to the right using sed.However, the script only manages to alter the final residue numberCould anyone please advise how I can loop through all values in $i and shift it one character to the right?

#!/bin/bash
# Script to alter position of residue number in pdb file for resid above 999
i=$(awk '{print $5}' wt-test.pdb | uniq)

[code]...

View 6 Replies View Related







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