...
From the above file, there is a date of birth in body (=020). I want to remove/substitute the dateofbirth with spaces. Like, 19750426 is the date of birth but want to substiute as spaces "1#7#0#2#". Want to do this same in all records in the file. Can you please tell me how to do this in shell script?
... A small change in my previous post. Instead of substitue the spaces, need to fill every 2nd character as # in the Date of Birth field.
...
You haven't mentioned if the date of birth part begins at a specific column in your file. If it does, and if you know that column number, then you can do something like the following Perl one-liner:
Code:
$
$ cat f1
010AAAAA 20100507 234KB BBBBBBBBBB_20100506.DAT
020CCCCC DDDDDDDDD 373983983 19750426 456.90 3983939EE
020FFFFF GGGGGGGGG 38938993H 19801102 783.33 DKJFDKJ983
030END OF FILE TOTAL 39839.22
$
$
$ perl -plne 's/^(020.{64})(\d).(\d).(\d).(\d).(.*)$/$1$2#$3#$4#$5#$6/' f1
010AAAAA 20100507 234KB BBBBBBBBBB_20100506.DAT
020CCCCC DDDDDDDDD 373983983 1#7#0#2# 456.90 3983939EE
020FFFFF GGGGGGGGG 38938993H 1#8#1#0# 783.33 DKJFDKJ983
030END OF FILE TOTAL 39839.22
$
$
Over here I know that date of birth begins from column 68 in rows that start with "020". Hence I put "64" in the brace quantifiers so that total length of the part before it is 3 (length of "020") + 64 = 67.
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this:
$ look "string" "/home/patrick/filename.txt"
However, this gives me the following message:
"look: /home/patrick/filename.txt: File too large"
So, I have two... (14 Replies)
Hello everyone
Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried
sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
logs:
"/home/abc/public_html/index.php"
"/home/abc/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
how to use "cut" or "awk" or "sed" to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
Discussion started by: timmywong
8 Replies
7. Post Here to Contact Site Administrators and Moderators
Majority of the questions are pertaining file/string parsing w.r.t
sed
or
awk
It would be nice to have these two as their own sub category under shell-programming-scripting which can avoid lot of duplicate posts. (1 Reply)
Hello All,
I have something like below
LDC100/rel/prod/libinactrl.a
LAA2000/rel/prod/libinactrl.a
I want to remove till first forward slash that is outputshould be as below
rel/prod/libinactrl.a
rel/prod/libinactrl.a
How can I do that ??? (8 Replies)
Hi Experts,
I have a string with colon delimited, want 2nd colon to be changed to a pipe.
data:
101:8:43:4:72:14:41:69:85:3:137:4:3:0:4:0:9:3:0:3:12:3:
I am trying with sed, but can change only 1 occurance:
echo "101:8:43:4:72:14:41:69:85:3:137:4:3:0:4:0:9:3:0:3:12:3:" | sed 's/:/|/2'... (5 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies
LEARN ABOUT DEBIAN
ample.html
AMPLE.HTML(5) User Manual AMPLE.HTML(5)NAME
ample.html - html template for Ample
DESCRIPTION
This file, by default /etc/ample/ample.html, is read by Ample at startup and used as a base for it's HTML pages. These pages are rendered
whenever a webbrowser connects and requests a list of available songs and directories (typically done by connecting to
http://server:port/index.html).
The file is divided into three sections, the header, the middle and the footer. The header and the footer are the same on each page gener-
ated while the "middle" is copied into the final HTML document once for each file or directory that is going to be listed. Although this
may sound confusing, it will probably become much more evident once you look at the example below.
Variables are written in uppercase and enclosed within "at" signs (example: @NAME@) and are replaced dynamically when the page is con-
structed. Some variables can exist anywhere in the document and some can only exist in the "middle" section, see the information about
each variable for details.
EXAMPLE
<!-- Beginning of header -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>@SERVERNAME@</title>
</head><body>
<center>
<p><h1>@SERVERNAME@</h1></p>
<p><h2>Tracks currently available in @PATH@</h2></p>
<p><font size="-1">[
<a href="index.m3u">playlist for this dir</a> |
<a href="rindex.m3u">recursive playlist</a> ]
</font></p>
<p><font size="-1">
[ <a href="../index.html">Up one level</a> ]
</font></p>
<div align="center">
<table border="1" cellspacing="0" cellpadding="0" bordercolor="#000000">
<tr><td>
<b>TYPE</b>
</td><td>
<b>URL</b>
</td></tr>
<!-- End of header -->
@BEGIN@
<!-- Beginning of "middle" -->
<tr><td>
@TYPE@
</td><td>
<a href="@URL@">@NAME@</a>
</td></tr>
<!-- End of "middle" -->
@END@
<!-- Beginning of footer -->
</table>
</div>
<p align="right"><font size="-1">
powered by Ample, for more information, see the
<a href="http://ample.sourceforge.net">project homepage</a>
</font></p>
</center>
</body>
</html>
<!-- End of footer -->
SUMMARY OF VARIABLES
SPECIAL - Only used once
BEGIN
END
GLOBAL - Can be used anywhere
SERVERNAME
PORT
PATH
NON-GLOBAL - Can only be used in the "middle" section
NAME
URL
LENGTH
TITLE
SIZE
TYPE
SPECIAL VARIABLES
These can only be used once.
BEGIN This variable (when placed in the beginning of a new line) marks the end of the header section and the start of the "middle" sec-
tion.
END This variable (when placed in the beginning of a new line) marks the end of the "middle" section and the start of the footer sec-
tion.
GLOBAL VARIABLES
These can be used anywhere.
SERVERNAME
The name of the server as given in ample.conf(5).
PORT The port that the server is listening to.
PATH The current path the user is viewing.
NON-GLOBAL VARIABLES
These can only be used in the "middle" section.
NAME The name of the song or directory.
URL The URL of the song or directory.
LENGTH The song length (in seconds) or blank if it is a directory.
TITLE The title of the song or "DIR" if it is a directory.
SIZE The file size or blank if it is a directory.
TYPE "FILE" if it is a file or "DIR" if it is a directory.
AUTHOR
David Hardeman <david@2gen.com>
SEE ALSO ample(1), ample.conf(5)Ample JANUARY 2002 AMPLE.HTML(5)