General :: Bash Script To Parse A File To Get A Set Of Line Between A Specific Characters?

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


ADVERTISEMENT

General :: Parse A File And Print Each Line That Ends With Matching Pattern (if The Next Line Is Blank)

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

Programming :: Change A Line In A File Code - Sed Special Characters Bash Script

Jan 26, 2011

I'm having issue when trying to change a line in a file

[Code]....

View 1 Replies View Related

General :: Bash : Pass Command Line Arguments Containing Special Characters?

Jul 14, 2010

I've written myself a linux program "program" that does something with a regular expression. I want to call the program in the bash shell and pass that regular expression as a command line argument to the program(there are also other command line arguments). A typical regular expression looks like "[abc]_[x|y]".Unfortunately the characters [, ], and | are special characters in bash. Thus, calling "program [abc]_[x|y] anotheragument" doesn't work. Is there a way to pass the expression by using some sort of escape characters or quotation marks etc.?

(Calling program "[abc]_[x|y] anotheragument" isn't working either, because it interprets the two arguments as one.)

View 7 Replies View Related

General :: Bash: How To Pass Command Line Arguments Containing Special Characters

Jun 24, 2011

I've written myself a linux program "program" that does something with a regular expression. I want to call the program in the bash shell and pass that regular expression as a command line argument to the program (there are also other command line arguments). A typical regular expression looks like "[abc]_[x|y]". Unfortunately the characters [, ], and | are special characters in bash. Thus, calling "program [abc]_[x|y] anotheragument" doesn't work. Is there a way to pass the expression by using some sort of escape characters or quotation marks etc.? (Calling program "[abc]_[x|y] anotheragument" isn't working either, because it interprets the two arguments as one.)

View 8 Replies View Related

General :: Write A Bash Script To Parse A Text File?

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

Programming :: Replacing Set Of Characters In A Specific Line Using Sed Or Awk?

Dec 29, 2010

I would like to replace 'xxxx' with 'yyyy' which is in a file xyz.csproj not sure of what 'xxxx' is, it can be 3055, 4056, 7089 etc. I know it always appears at line # 5 and at character 50.

<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Windows.Forms" />

[code]....

View 14 Replies View Related

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

General :: Change A Specific Characters To Capital In A Specific Text?

Dec 2, 2010

for example

else {
for fileDOC in $location/*.doc
do

[code]...

View 12 Replies View Related

Programming :: Parse Multiple Variable From Text File With Bash?

Jul 13, 2010

I am trying to think of a logic where my file contains some data I had to read and do some processing. Issue is that file contains data multiple times. For example:

:::::::::::
var1=value1
var2=value2

[code].....

I have to read first paragraph of variables and do some processing and then move on until the end of file. Variable names are same in whole file but for each paragraph the value is different. I can't think of a logic to attain this task. How can I do it? It should be a simple bash script, but I am not able to work out.

View 2 Replies View Related

General :: Showing The Line Count Of A Specific File

Mar 30, 2011

Is this the correct way to show the line count of a specific file?

cat file | grep * -c

View 3 Replies View Related

General :: Removing A Line From File Which Is Having Specific Pattern Using Shell Script?

Mar 20, 2011

I'm new to the shell scripting. can any one help in creating shell script for matching the content of the specific variable with file. it should remove that line from the file if line is containing same value as variable and keep the other content as it is.i used grep -v for accomplishing the same. But grep will remove the pattern which is similar.For eg. Assume file "test" contain datas :aaffif i used grep -v command for the pattern "a" to this file this will remove content "aa" from the file. I want the pattern only "a" should remove from the file, if it is existing. otherwise it should throw alert content not exists.

View 5 Replies View Related

General :: Sort By Line Size (number Of Characters In A Line)?

Jan 8, 2010

I want to sort a number of lines based on their size:

data:
-------
12345678
87654321
1234

[code]....

Should output as:
-----------------
1
2
12
21

[code]....

But i'm gettings this with sort
----------------
1
12
123
1234

[code]....

Can we sort the above "data" text, based on "number of characters" instead of "character order"?

View 8 Replies View Related

General :: Parse String In Bash Script?

Nov 8, 2009

I have to create a bash script that takes an arbitrary length number from the command line, and add up each individual digit

Ex:
server> myscript.sh 123
server> 1 + 2 + 3 = 6

The problem I'm having is pulling out each character.

Is there a way in bash I can parse the input string for each character? I can't figure out a way to do this.

View 4 Replies View Related

General :: Parse Command Line Arg Using Getopt()?

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

Programming :: Bash: Read A Text File Line By Line?

Jul 7, 2011

bash 3.1.17(2) I'm trying do write a shell script which must operate on each line of an ASCII text file. So, all the code must be inside a loop, and inside the loop, the first thing should be to read the next line from the file. I have the bash read command. But it reads from stdin. Any way to make read from a file?

View 6 Replies View Related

General :: Shell Scripting: Parse Parameters From Command Line?

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

General :: How To Delete A Line At Specific Line Number

Jun 15, 2010

I m writing a script to delete a line at particular location.

But i m unable to use variable for specifying line number.

For example.

Code:

works fine and deletes 7th line from my file

But

Code:

gives following error.

Code:

View 7 Replies View Related

Programming :: Bash Script To Locate A Specific File?

Jun 14, 2010

I'm new to bash scripting and I've searched around the forums and Internet for this but haven't had any luck. I've found similar things but not what I need. What I need to do is write a simple script that uses what the user inputs to locate and display where a file is. I would prefer to use locate instead of find since I know that the person I am writing this for has locate on her machine (my mom, who is just beginning with Linux).I'm writing the script to make things easier for her while she learns In this particular part of the script I would like to be able to have the script prompt to enter the file she is searching for, read the her input and then display for her where the file is. I realize it would in most cases be much simpler just to teach her how to use locate, but she is very impatient and this is just a part of the script I will be writing, but I can't figure out how to do this.

View 6 Replies View Related

Programming :: Get The Specific Text From A Txt File In Bash Script?

Apr 30, 2010

I have a text file which stores the list of files & dir, I want to get only file's extensions from this file & want to store it in another file.eg, below is the file's contents & from it I want to get the extensions sh, pl & h & want to store it in another file. Also I don't want directory list.

A scripts/services_restarter.sh
A scripts/svn post_commit scripts
A scripts/tmp/

[code]...

View 8 Replies View Related

General :: How To Put Some Characters On The End Of A Line

Nov 1, 2010

We have a list of cyclones in the world. Now i got to check whether or not the second field is more than 1000 mm. If so, than the line has to have a[*] at the end of the line. For exemple:

Australia:1411:55.55:Mackay Cyclone 1918:1918:Mackay
to
Australia:1411:55.55:Mackay Cyclone 1918:1918:Mackay[*]

I also have to use a substitute. So far i've got this but it fails, 6,$s/([0-9])111:1/.* [*]

View 7 Replies View Related

Programming :: Parse HTML And Print Specific Table?

May 13, 2009

I'm trying to write a script that will spider a particular webpage that shows the current inventory for their products. I need to figure out the optimal method of parsing the web page, and extracting the <td> line for the "qty" for "Product 2":

Code:

<table border="0" width="100%" cellspacing="1" cellpadding="3">
<tr>
<td align="left" style="background-color: #EAEAFF; border-bottom-style: solid; border-bottom-width: 1" nowrap width="20%" height="50">
<p align="left"><font face="Arial" size="2"><b> Evaluation

[code[.....

View 4 Replies View Related

General :: Parse File From Remote Server To Caculate Count Of String Existence In That File?

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

Programming :: Copy And Replacing Specific Line From File1 To File2 Line By Line

Mar 22, 2011

I have two files, file1.traj and file2.traj. Both these files contain identical data and the data are arranged in same format in them. The first line of both files is a comment.

At line 7843 of both files there is a cartesian coordinate X, Y and Z ( three digits ). And at line 15685 there is another three digits. The number of lines in between two cartesian coordinates are 7841. And there are few hundreds of thousands of lines in a file.

What I need to do is copy the X Y Z coordinate (three digits) from file1.traj at line 7843 and paste into file2.traj at the same line number as in file1.traj. The next line will be 15685 from file1.traj and replace at line 15685 at file2.traj. And I dont want other lines (data) in file2.traj get altered. This sequence shall be going on until the end of the file. Means copy and substitude the selected lines from file1.traj into file2.traj.

I tried to use paste command but I cant do for specified line alone.

Here i showed the data format in the file. I used the line number for clarity purpose.

Code:

View 10 Replies View Related

General :: Moving Characters To The End Of Line (EOL) With SED?

Sep 13, 2010

Any time the word The appears at the beginning of a line, I want to move it to the end of the line and capitalize the new first word in the line. For example, The heaven becomes Heaven the. I'm trying to test this out for my Library.

View 2 Replies View Related

General :: Bash Prompt Loses Characters?

Apr 17, 2011

After writing a new prompt for Bash, I noticed that one character of my commands were being lost when it wrapped to the new line. Here is an image of the example (I typed 1234567890 over and over):

Here is my $PS1

PS1="
[[e[0;90m]d [e[0m]] [[e[0;90m]$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, $(/usr/bin/du -sh | cut -f1)[e[0m]
[[e[0;36m]#[e[0m]] [e[0;95m]u[e[0;90m]@[e[1;92m]h[e[0m]: [e[1;34m]w [e[1;30m]$[e[0m] "

What have I done wrong?

View 1 Replies View Related

Ubuntu :: Error Dpkg: Parse Error, In File '/var/lib/dpkg/available' Near Line 2 Package 'x11proto-core-dev'

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

General :: How To Strip/trim Characters In Command Line

Mar 23, 2011

I have a bunch of files (around 900) that have some special characters. Some of the files contains example, and quoting "[useless] filename (something)"so what I want is just to strip the brackets and parenthesis, some are folders, others are text files

View 1 Replies View Related

General :: PuTTY And 256-color - Line Drawing Characters ?

May 3, 2011

I'm having trouble setting up PuTTY with Ubuntu. I'm trying to get line characters to work in aptitude as well as 256-color support, but can only get one or the other.

Ubuntu Config:

Using 64-bit Ubuntu
Terminal type xterm-256color or putty-256color gives 256-color, but incorrect line characters.
Terminal type linux gives proper lines in aptitude, but only 16 colors.

PuTTY Config:

Using font with Unicode characters. (DejaVu Sans Mono)
Received Data is assumed to be in UTF-8.
Set to use Unicode line drawing code points.

Output from locale:

View 1 Replies View Related

General :: Playing With Various Characters In The Command- Line Interface?

Apr 23, 2010

I am playing with various characters in the command- line interface trying to learn what they mean and when i should use them.

View 7 Replies View Related







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