04-19-2011
Reading a file and replacing char by position
Hi
I'm looking for a way to read a text file that may contain 1000 records or more and each of these records has 460 characters. I need to read each record, and add a string of characters starting at position 256 for each record. Any suggestions using UNIX shell scripting.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have a file where some records have been updated the wrong way and need to fix it quickly since the amount can be alot.
Every record where any of the first 4 characters are in upper case need to be changed to lowercase.
Records can have '#' in position-1 for comments. These musn't be... (2 Replies)
Discussion started by: Browser_ice
2 Replies
2. Programming
how we can replace char with a string
example
char *a="a.s"
so finally
what i ant to do
raplace a with ant and s sree
so in my array a i want to store the value as "ant.sree"
thank u in advance (1 Reply)
Discussion started by: phani_sree
1 Replies
3. Shell Programming and Scripting
Hi
I'm trying to use awk in a file(test123.dat).
My requirement is to to check for the 65th position, if the 65th position is a space then replace the 65th position by the number 9.
This is the code that i used:
awk '{substr($0,65,1) ~ / / }{sub(substr($0,65,1),"9")}{print}' test123.dat
... (7 Replies)
Discussion started by: angelarosh
7 Replies
4. Shell Programming and Scripting
Hi all,
I am trying to find the best way of making a change to 1 char in a string, the string can be between 1 and 14 characters.
I am reading a line in from a file which contains
012341231231:2:102939283:NNN: Require :NBN:
012838238232:3:372932:NNN: Require :NNB:
I need to change 1 N or a... (8 Replies)
Discussion started by: nkwilliams
8 Replies
5. Shell Programming and Scripting
I need to list all files where 1rst column=ABK and char position 123 to 125=ZBK:
For the first part I can I can do a awk '{$1="ABK";print}' file and for the second a cut -c123-125 file | grep ZBK but this would only work partially..
How can I do this with only one awk command ?
Thanks in... (10 Replies)
Discussion started by: cabrao
10 Replies
6. Shell Programming and Scripting
hi,
i have a file with delimiter "þ" . how to read these delimiters filters like AWK and cut..:wall:
Thanks,
Soma (1 Reply)
Discussion started by: challamsomu
1 Replies
7. UNIX for Dummies Questions & Answers
Hi
I'm trying to remove what I "think" is a bad character. How I got the bad character is when I downloaded jpgs onto my PC and then renamed the files using windows explorer. In cygwin, the files look like
$ dir -l
total 7840
----------+ 1 None 3647968 Jul 21 08:41 2012-07-21\ (1).JPG... (6 Replies)
Discussion started by: SailingDreams
6 Replies
8. Shell Programming and Scripting
Hi experts,
Need your help on how to insert carriage return after the 10th char position of each line in a file and then add two blank spaces after the carriage return.
Example:
>cat test.txt
testingline
dummystring
samplesample
teststringline
Expected output should be..
... (2 Replies)
Discussion started by: brichigo
2 Replies
9. UNIX for Dummies Questions & Answers
Hi
I've a string . And i need to replace set of characters with a single character
Means .. or . or ... and so on should be replaced with single % character
Irrespective of number of dots in between the characters , those should be replaced with single %
All the above strings should be... (3 Replies)
Discussion started by: smile689
3 Replies
10. UNIX for Beginners Questions & Answers
Hello All,
I have a file as below . I want to convert the Y with numbers to H
From
4,
M11,
P2521759,
Y75,Y70,Y105,Y110,Y700,Y815,Y830,Y900,Y162,Y300,
Y291,Y290,Y15,Y20,
MR2716014,MR2617014,
Yesterday,current
1,201012,
102032,1
11112,0
to
4,
M11,
P2521759,... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies
fwtmp(1M) fwtmp(1M)
NAME
fwtmp, wtmpfix - manipulate connect accounting records
SYNOPSIS
[files]
DESCRIPTION
fwtmp
reads from the standard input and writes to the standard output, converting binary records of the type found in to formatted ASCII records.
The ASCII version is useful to enable editing, via ed(1), bad records or for general purpose maintenance of the file.
The argument is used to denote that input is in ASCII form, and output is to be written in binary form. The arguments and are independent,
respectively specifying ASCII input and binary output. Therefor, is an ASCII to ASCII copy and is a binary to binary copy. should be used
for reading If is not used, structure is read.
wtmpfix
examines the standard input or named files in format, corrects the time/date stamps to make the entries consistent, and writes to the stan-
dard output. A can be used in place of files to indicate the standard input. If time/date corrections are not performed, will fault when
it encounters certain date-change records.
Each time the date is set, a pair of date change records is written to The first record is the old date denoted by the string old time
placed in the line field and the flag placed in the type field of the structure. The second record specifies the new date, and is denoted
by the string placed in the line field and the flag placed in the type field. uses these records to synchronize all time stamps in the
file. nullifies date change records when writing to the standard output by setting the time field of the structure in the old date change
record equal to the time field in the new date change record. This prevents and from factoring in a date change record pair more than
once.
In addition to correcting time/date stamps, wtmpfix checks the validity of the name field to ensure that it consists solely of alphanumeric
characters or spaces. If it encounters a name that is considered invalid, it changes the login name to and writes a diagnostic to the
standard error. This minimizes the risk that will fail when processing connect accounting records.
DIAGNOSTICS
wtmpfix generates the following diagnostics messages:
WARNINGS
generates no errors, even on garbage input.
FILES
SEE ALSO
ed(1), acct(1M), acctcms(1M), acctcom(1M), acctcon(1M), acctmerg(1M), acctprc(1M), acctsh(1M), runacct(1M), acct(2), acct(4), utmp(4),
wtmps(4).
STANDARDS CONFORMANCE
fwtmp(1M)