10-17-2007
replace at specifcposition
Hi
#xxxxx abced
xxx_hij=
The above are two lines in a file. I would like to parse the file write a text line between the above two lines...like
#xxxxx abced
<write a text line here>
xxx_hij=
How can I do this using sed or awk? also if there is any other easy way apart from sed and awk pls. let me know
Thanks!
10 More Discussions You Might Find Interesting
1. Linux
Hey i've got a laptop that is my main computer right now and i wanted to put something *nix on it. However i do need something that will run some of my windows apps... mostly my games haha. I don't want to have to run a third party app like wine. Which distros would be right for me? (2 Replies)
Discussion started by: byblyk
2 Replies
2. Shell Programming and Scripting
Hi Dudes,
I want to replace \n with \r\n through out the file. For this I opened vi editor there tried with " s/\\n/\\r\\n/g ", with this I must be able to satisfy my requirements. But it is searching for the current line (Where cursor is). I need this for entire file. No problem if it is... (3 Replies)
Discussion started by: Chanakya.m
3 Replies
3. Shell Programming and Scripting
Hi:
I want to write a Kshell script which will replace last / by |.
eg: /home/apps/test/document should be replaced as /home/apps/test|document.
The length of the string is not constant.
Thanks,
Ash (6 Replies)
Discussion started by: naikaa
6 Replies
4. UNIX for Dummies Questions & Answers
Hi All,
How to add a '*' at the begining of VI file between lines in a range say 20 -30??
Please help.
I tried :%s/20,30/^/\*/
Did not work.
Thanks and Regards,
Gideon. (3 Replies)
Discussion started by: preethgideon
3 Replies
5. Shell Programming and Scripting
I am having a dificult time trying to replace 2 carriage returns and 1 newline with 1 carriage return and 1 newline in a file. The file may come as CR NL in which case I need to leave it as is. When it comes with CR CR NL then I need to remove one of the CR's.
i tried
sed 's/\r\r\n/\r\n\g'... (6 Replies)
Discussion started by: hanton
6 Replies
6. Shell Programming and Scripting
Hello,
I really would appreciate some help with a bash script for some string manipulation on an SQL dump:
I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump.
This is quite easy with sed:
sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies
7. Shell Programming and Scripting
I need to replace dashes (i.e. -) if present from positions 351-357 with zero (i.e. 0), I also need to replace dash (i.e “-“) if present between position 024-043 with zero (i.e. 0) & I replace " " (i.e. 2 space characters) if present at position 381-382 with "04". Total length of record is 413.... (11 Replies)
Discussion started by: lancesunny
11 Replies
8. Shell Programming and Scripting
Hi experts,
I have a csv file where the delimiter is comma and the text between apostrophe.
Like this:
"aaa","bbb","ccc","ddd","eee","fff","ggg"
But now i have a lot of enter(end of line) in text like this:
"aaa","bbb","ccc","ddd","eee","
""
""
fff","ggg"
How can i remove that... (8 Replies)
Discussion started by: snayper
8 Replies
9. UNIX for Dummies Questions & Answers
I need to replace the (*) in the fist of a list with numbers using sed for example >
this file contain a list
* linux
* computers
* labs
* questions
to >>>>
this file contain a list
1. linux
2. computers
3. labs
4. questions (7 Replies)
Discussion started by: aalbazie
7 Replies
10. UNIX for Beginners Questions & Answers
I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies
LEARN ABOUT DEBIAN
arch::diffparser
Arch::DiffParser(3pm) User Contributed Perl Documentation Arch::DiffParser(3pm)
NAME
Arch::DiffParser - parse file's diff and perform some manipulations
SYNOPSIS
use Arch::DiffParser;
my $dp = Arch::DiffParser->new;
# usable for "annotate" functionality
my $changes = $dp->parse_file("f.diff")->changes;
$dp->parse($diff_content);
$dp->parse("--- f1.c 2005-02-26
+++ f2.c 2005-02-28
...");
# prints "f1.c, f2.c"
printf "%s, %s
", $dp->filename1, $dp->filename2;
# enclose lines in <span class="patch_{mod,orig,line,add,del}">
my $html = $dp->markup_content;
DESCRIPTION
This class provides a limited functionality to parse a single file diff in unified format. Multiple diffs may be parsed sequentially. The
parsed data is stored for the last diff, and is replaced on the following parse.
METHODS
The following class methods are available:
new, parse, parse_file, content, lines, filename1, filename2, mtime1, mtime2, hunks, changes.
new Construct the "Arch::DiffParser" instanse.
parse diff_content
Parse the diff_content and store its parsed data.
parse_file diff_filename
Like parse, but read the diff_content from diff_filename.
diff_data
Return hashref containing certain parsed data. Die if called before any parse methods. The keys are: "lines", "filename1", "filename2",
"mtime1", "mtime2", "hunks", "changes".
The value of "hunks" and "changes" is arrayref of arrayrefs with 5 elements: [ line-number-1, num-lines-1, line-number-2, num-lines-2,
"lines"-index ].
A "hunk" describes a set of lines containing some combination of unmodified, deleted and added lines, a "change" describes an inter-
hunk atom that only contains zero or more deleted lines and zero or more added lines.
lines
filename1
filename2
mtime1
mtime2
hunks
changes
These methods are just shortcuts for diff_data->{method}.
content [%args]
Return content of the last diff.
%args keys are "fileroot1" and "fileroot2"; if given, these will replace the subdirs "orig" and "mod" that arch usually uses in the
filepaths.
markup_content [%args]
Like content, but every non-context line is enclosed into markup <span class="patch_name">line</span>, where name is one of "orig"
(filename1), "mod" (filename2), "line" (hunk linenums), "add" (added), del (deleted).
Not implemented yet.
BUGS
No support for newlines in source file names yet.
AUTHORS
Mikhael Goikhman (migo@homemail.com--Perl-GPL/arch-perl--devel).
SEE ALSO
For more information, see Text::Diff::Unified, Algorithm::Diff.
perl v5.10.1 2005-03-09 Arch::DiffParser(3pm)