hello every one
I have file with following records
for each record there is ASX word then 9 digits after it (NO spaces included)
what i want is to :
1- skip ASX
2-skip first 2 digits after ASX word
3- check digits 3-5, if all zeros then ok, go to next record
4- if any digit from 3 to 5 is a number then check digit 8
if digit 8 is 1 or 2 then make digits 3-5 zeros
if digit 8 is NOT 1 or 2 then ok go to next record
According to the above records, the output should be:
i tried sed command but i could not figure the right syntax..
please how to do it
Thanks alot Radoulov. It works on hp-ux.
however, I put small records to clear my point..since i'm confused with the sed script you applied, i'll put the exact number of digits in the record
usually the record is like:
ASX(9 digits)(3 digits to be checked if they are zeros or numbers)(36 digits)(1 digit to be checked if it is 1 or 2)(5 digits)
Thank you radoulov, you are right, i thought the short records would be easier for the reader .. i was wrong ..
we receive many files daily, The longest file records we receive like this:
1- skip ASX
2-skip first 16 digits after ASX word
3- check digits 17-23, if all zeros then ok, go to next record
4- if any digit from 17 to 23 is a number then check digits 101 to 103
if digits 101 to 103 is 001 or 002 then make digits 17-23 zeros
if digits 101 to 103 is NOT 001 or 002 then ok go to next record
The output should be:
another thing is how to assign a record, from above records that meet the conditions, to a variable
ex
orgv=record has NO zeros in digits from 17 to 23 and has 001 or 002 in digits 101 to 103
the reason for the variable is to grep it from the file..then use if statement to do the action if it is true (some times we receive file has the right records that do not need to be changed..)
because the sender sends these files to many receivers, we can't fix it from the sender
I have a test file a.txt
001 123 456 789
002 This is just a
001 test data
003 file.
I want to clear columns 5 and 6 if the first 3 characters are 001 using awk.
I tried following but does not work. Any suggestions?
awk 'BEGIN{OFS=FS=""} {if (substr($0,1,3)=="123") $5=" "; $6="... (20 Replies)
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)
Dear All,
I am struggling with the following task and would appreciate some help. I have a large table (file1.txt). The first column of this table contains an ID. I would like to replace the ID with a label according to a reference file.
Here is an example:
cat infile.txt
0 AJ2312 310 ... (7 Replies)
hello everyone
i searched the net and i could not find script for this request.
i believe sed command will do it but i'm not sure about how.
my file contains thousands of records, the following is sample:
BEGIN
ASX15001
BEGIN
ASX15000000500020101230
ASX18001020070002010123... (10 Replies)
hi,
i have various csv files, the file format is as follows
Entry: "1",4,2010/08/15-10-00-00.01,,"E",,,,,,,,,120,0,"M4_","C","KEW-011-5337140-20100916163456-540097","1234567890","N N 0 ",,,"NUK 800100200",,,"NN",,,,,,,,,,,,"0000000001|0001|20150401... (2 Replies)
hey,
I have a file with numbers in US notation (1,000,000.00) as well as european notation (1.000.000,00)
i want all the numbers to be in european notation.
the numbers are in a text file, so to prevent that the regex also changes the commas in a sentence/text i thought of:
sed 's/,/\./'... (2 Replies)
I have a file which has about 10000 records and I need to delete about 50 records from the file. I know line numbers and am using
sed '134,1357,......d' filename > new file.
It does not seem to be working.
Please Advice (5 Replies)
I have two files one (numbers file)contains the numbers(approximately 30000) and the other file(record file) contains the records(approximately 40000)which may or may not contain the numbers from that file.
I want to seperate the records which has the field 1=(any of the number from numbers... (15 Replies)
I'm declaring a variable within a Korn shell to represent the total number of records in a SAS dataset and could use a little help with the syntax. This is what I have thus far:
#!/usr/bin/ksh
RecCount = `sas -x "select count(*) from /users/abc/123/sas_dataset.sas7bdat"` (2 Replies)