General :: Parse A Line From A File And Place The Values Into Separate Variables?
Sep 28, 2011
I am trying to parse a line from a file and place the values into separate variables:
input.txt:
Code:
CreateVegaFeed-20110928-before-skip-start
this is the code i have done so far:
Code:
$input_file="input.txt"
INPUT_FILE=`cat $input_file`
for i in $INPUT_FILE
[Code].....
View 14 Replies
ADVERTISEMENT
Apr 26, 2011
I need to parse through a file which contains timestamps of transactions. What I am trying to do is come up with a Max Transactions Per Second (TPS) value. I was thinking that creating an array variable would be the way to go, but I'm having problems determining even how to start.
View 4 Replies
View Related
Apr 13, 2010
I'm doing some bash-scripting and want to be able to print some text (just plain text) files into the new bash-scripts, created within a loop. Here's a short example of what I do:
Code:
# main bash script #
#!/bin/bash
##Filename
variable1=10
for ((j=0;j<=40;j+=1))
do
## Create another bash-script
echo "#!/bin/bash" >> bash_script_$j
... some stuff...
cat file1.txt >> bash_script_$j
... some more stuff...
done
where the text file (file1.txt) I want to print in the the new bash script looks something like:
Code:
# file1.txt #
...some stuff...
logsave log some_program($variable1)
mv output_$j folder_$j/
... some more stuff...
I.e, the text file contains variables such as "$j", "$variable1" etc that are undefined. Doing the above works for creating new bash scripts (bash_script_1 - bash_script_40) but the variables are not determined. I would like, if possible, to somehow print the text in file1.txt into the new bash-scripts with the variables determined, i.e:
Code:
# bash_script_1 #
...some stuff...
logsave log some_program(10)
mv output_1 folder_1/
... some more stuff...
The text files I read are quite extensive so I would really prefer not having to paste them into the FOR-loop directly.
View 2 Replies
View Related
Aug 2, 2010
I've written a script to parse a file and print each line that ends with matching pattern, if the next line is blank. The pattern lines are the result of md5sum $i|sed 's/path///g' so that only md5 and filename appear. Here's what I'm using.
Quote:
for fline in `sed -n '/.*.ext$/p' file1`
do
if [ "`sed -n -e '/'"$fline"'/ {n; p;}' file1`" == "" ]
then
echo ""$fline" has no info" >>file2
fi
done
[Code]....
View 4 Replies
View Related
Jun 9, 2010
Is there an easy way to get a line from a text file into a variable in a bash script?
I have a file called outside_temp that has a single number, say, 63.2
I would like to make a variable in a BASH script have that value.
I know how to use the input redirection and reassignment of stdin using code...
View 1 Replies
View Related
Dec 23, 2010
I have a log file that contains information like this:
----------------------------
r11141 | prasath-palani | 2010-12-23 16:21:24 +0530 (Thu, 23 Dec 2010) | 1 line
Changed paths:
M /projects/
M /projects/
[code]....
what i need is, i need to copy the data given between the "---" to seperate files, for, e.g. the first set of data between the "---" should be in one file and another set of data in another file.
View 5 Replies
View Related
Apr 15, 2011
How to parse the bunch of values displayed by the socket program into the php file so that further it can be displayed in HTML page
View 1 Replies
View Related
Apr 17, 2011
My php knowledge is very poor (only worked with strings so far), and I am faced which a task that is a real challenge for me: I have a variable, that contains data of different type, in this order: byte, byte, string, string, string, string, short, byte, byte, byte, byte, byte, byte, byte, string.
Strings are of variable length. How could this data be parsed into variables of the right type, and then all converted to strings? What are the functions to use? Strings are unicode ones, and they are delimited by "
View 4 Replies
View Related
Dec 10, 2010
I have the following code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
system("ps -ef | grep myprocessname");
return 0; }
When I run this program it outputs the following list of running processes:
Code:
root 10279 10275 0 13:02 ? 00:00:00 myprocessname myvar1=value1 myvar2=value2
root 10341 10337 1 13:02 ? 00:00:00 myprocessname myvar1=value1 myvar2=value2
What I want to really do is instead of writing the output to screen I want to read the output and parse the various values value1, value2 etc. What is the best way to do this?
View 4 Replies
View Related
Apr 1, 2011
I am trying to parse command line arg using getopt().this is my code
int main(int argc, char** argv)
{
int a=0,b=0;
[code]....
View 1 Replies
View Related
Mar 12, 2010
myscript [-a a-arg] [-c c-arg] [-b] [-e] somedirectory
Given that I want my shell script be invoked at the command line using the above parameters - where [these brackets] denote that they are optional - what is the best method to parse them?
View 1 Replies
View Related
Jan 22, 2010
This is a Fix message - it is a type of protocol for transmitting financial dataeach number followed by a = sign is a tag - each tag means something. some tage are moe important than other.
8=FIX.4.1^9=0235^35=D^34=10^43=N^49=VENDOR^50=CUSTOME^ 56=BROKER^52=19980930- 09:25:58^1=XQCCFUND^11=10^21=1^55=EK^48=277461109^22= 1^54=1^38=10000^40=2^44=76.750000^59=0^10=165 18
[code]....
View 9 Replies
View Related
May 19, 2010
Code:
MY_STDOUT=`my-command`
MY_STDERR=`my-command >&2`
That is, i want to have to run my-command only once and get the same result. I've tried this:
Code:
YYY=$(XXX=`{ echo -n 111; echo 222 >&2; }` 2>&1); echo $XXX $YYY
where "{ echo -n 111; echo 222 >&2; }" is my-command. But it gives this output:
Code:
222
111
instead of "111 222". What's wrong in my script?
View 2 Replies
View Related
Aug 30, 2010
I need to parse the file of same name which exist on different servers and calculate the count of string existed in both files.Say a file abc.log exist on 2 servers.I want to search for string "test" on both files and calculate the total count of search string's existence.For example if file abc.log on server 1 has string "test" 2 times
and file abc.log on server 2 has string "test" 4 times.then the output will beStringName : Countexampletest : 6 timesNote : I have created the password less connectivity using ssh-keygen.
View 2 Replies
View Related
Jul 7, 2010
I have a problem with snmp answers being empty or having spaces.
What I already have:
#get all interface indexes (if you wonder - I'm working for a cable company and different cablemodems have different number and types of interfaces):
The problem is the physical address which is sometimes empty and the description which has spaces. So I'm doing 2 snmpgets which is slower than 1 snmpget (sometimes I have up to 18 interfaces).
I'm trying to explain it a bit simpler.
Interface 5 gives me back the following lines:
Ethernet CPE Interface
Now the first line should go into variable ifadm,
2nd line should go into variable ifoper,
3rd line should go into variable ifspeed,
4th line should go into variable iftype,
5th line (which is empty) should go into variable ifphys and finally
6th line (which has spaces) should go into variable ifdescr
View 4 Replies
View Related
Sep 18, 2010
When I tried to upgrade my xubuntu 10.04 , I got this error
dpkg: parse error, in file '/var/lib/dpkg/available' near line 2 package 'x11proto-core-dev': value for `status' field not allowed in this context E: Sub-process /usr/bin/dpkg returned an error code (2)
View 5 Replies
View Related
May 5, 2010
I'm extracting data from a xml file writing it to separate files then combining the results as a csv file.The problem is keeping the separate files in sync line by line.When a grep does not action I would like to put in a blank line or something to keep the lines in order.When the "<title>" is missing as in as in the first"<programme </programme>" that's where I need somethingto write to the file as dummy data to increment the line
here's the data
Code:
<programme channel="15552.dvb.guide" start="20100504200000" stop="20100504204000">
<category>Show / Game Show</category>
</programme>
<programme channel="14498.dvb.guide" start="20100504200000" stop="20100504203000">
[code]....
View 14 Replies
View Related
Nov 17, 2008
I want to write a script to find out the journal size of an ext3 file system. I have two commands (graciously provided by unSpawn):
Code:
The journal is located at inode:
'tune2fs -l /dev/device | awk '/Journal inode/ {print $3}''
The size is:
debugfs -R "stat <inodenumber>" /dev/device 2>&1| awk '/Size: / {print $6}'|head -1
These commands work okay from the command line. I wanted to do something like code...
View 3 Replies
View Related
Apr 5, 2010
I am working on the script to parsing the specific message like "aaaa" in multiple log files like N1-***,N2-***,N3-***..The script is to find the list of lof files which contains the message "aaaa" and export the list into excel filE.
View 4 Replies
View Related
Apr 29, 2011
Go to a specified directory and open a log file and parse out specific information and dump it into another text file.
View 4 Replies
View Related
Apr 27, 2011
I want to write a bash script to parse a text file with the following lines and set variables for each line so that I can use them in the rest of the script.
Timestamp=123456789
Company=ABC Company
Server=Server
Recipient=Joe Smith
Email=joe@abc.com
simplest way to read each line one at a time for everything before the =, set that to a variable name with the value equal to everything after the =
View 14 Replies
View Related
May 26, 2011
how to retrive every portion separately from following file name? DSA4020_frontcover_20346501_2011-05.doc
I want to retrieve informations as below;
name = DSA4020
type = frontcover
id = 20346501
date = 2011-05
is it possible to do with sed??
View 4 Replies
View Related
May 14, 2010
I have the following values in my log file:
...
2010-05-13 11:00:00 k_TRANSFER OK (11)
2010-05-13 11:30:01 m_TRANSFER OK (21)
2010-05-13 12:00:00 k_TRANSFER OK (12)
2010-05-13 12:30:00 m_TRANSFER OK (32)
2010-05-13 13:00:00 m_TRANSFER OK (13)
...
I want to replace every number with it's decrement. For example, the above values should be:
...
2010-05-13 11:00:00 k_TRANSFER OK (10)
2010-05-13 11:30:01 m_TRANSFER OK (20)
2010-05-13 12:00:00 k_TRANSFER OK (11)
2010-05-13 12:30:00 m_TRANSFER OK (31)
2010-05-13 13:00:00 m_TRANSFER OK (12)
View 5 Replies
View Related
Jan 16, 2011
Source:
Code:
JAMES ::: AAAA ::: 1111
JANET ::: BBBB ::: 2222
LAURA ::: CCCC ::: 3333
[Code].....
Is there a way to do this from command line?
View 7 Replies
View Related
Dec 8, 2010
When connecting to a database in a php script, where would be the safest place to store the connect.php file. I am thinking it should not be in public_html, but is it safe in sub folders or is there a method people generally use to keep such files secure and inaccessible.
The file I mean is one including the database name, user and password etc.
View 2 Replies
View Related
Jun 10, 2011
I want to read values from a file...these are basically one word values, that is to say that the text file I want to read from contains lines of word length 1, as in:
word1
word2
word3
[code]...
View 4 Replies
View Related
Jan 14, 2010
I would like to grep all values other than encrypted password from /etc/shadow fileFor example,each line consists of 8 fields separated with :/The only thing that I want not to print out is the contents between first : and second : (encrypted password)
View 7 Replies
View Related
Sep 6, 2010
I've just upgraded to 11.3, as a result, the suse-supplied video driver runs very slowly (screen-saver updates about 2 fps, to give you an idea) On 11.2, I had installed nvidia's native driver and things were just fine, so I tried to install the latest nvidia driver again, but I'm getting a hard hang with Yast -- at 99% downloaded, yast stops responding ("abort" doesn't respond, but an external "kill" signal works)
Finally getting the bright idea of checking the y2log file, I see the following code...
these three lines are repeated every second
I'm sure there are some fingers to be pointed [nvidia's ftp server is borked; aria2c is clueless, etc] but that does not help me - what do I need to do to convince this "aria2c" program that the file has, in fact, completely downloaded so that the installation process can continue?
View 6 Replies
View Related
Nov 4, 2010
I have to read a couple of numbers from a random.txt file. In this .txt file there are random numbers. They are separated by a space. Example if you opened test.txt:
test.txt :1 6 1 3 6 8 10 2 4
I would like to read those numbers using CAT and store them into an array:
numlen=${#num[*]} - (must be like this because it is a part of a larger program)
View 5 Replies
View Related
Apr 16, 2011
I am trying to include my directory /usr/sbin in it's serch path for executable files using an environment variable. Would the input be: PATH="/usr/sbin"? And also upon start up, my shell should create the PRINTER environment variable which should resolve to the word sales...would that input be: PRINTER="sales"? If someone could help me with these two questions,
View 3 Replies
View Related