Are there any characters in you input other than colon, comma, period, open and close parentheses, and digits?
Nope, just digits, colons, commas, and parentheses
Is this a line in a file or is it the value stored in a shell variable? If it is in a file, will there be more than one line?
The lines are in a text file. Files have between 1 and 1000 lines
What OS are you using?
Mac OSX
Is the letter you want to add always a uppercase A?
No. I could add any letter, upper or lower case.
Will the parentheses always be arranged the same way?
Yes
Will there always be 3 numbers you want to keep and 1 colon after each number you want to keep?
I want to delete the four digits and decimal point after the colon and retain the digits before the colon. The number after the colon is always x.xxx and the number before the colon is either one digit or two but never three
I thought I could do something like this: awk \:\d\.\d+ file > file_b for the first task at least, but have not been successful. Thank you for your help!
The following seems to do what you want:
assuming your input is in a file named "file". If anyone wants to try this scrip using a Solaris/SunOS system, they should use /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk instead of awk.
With the input you specified in the 1st message in this thread, the output produced is:
If you'd like to use some string other than "A" before the numbers added in the output, change the value assigned to letter in the first line of code.
---------- Post updated at 18:19 ---------- Previous update was at 18:00 ----------
With a version of sed that conforms to the standards (including the sed available on OS X), Yoda's sed command can be simplified to:
and still produce the same output.
This User Gave Thanks to Don Cragun For This Post:
Hello Team,
Could you please help me with the below question?
I have a file with the following properties
1) File Delimiter is ;
2) Text columns are within double quotes
3) Numeric columns will not have double quotes
4) File has total 6 columns
Please see a sample record from file
... (3 Replies)
Dear folks
Hello
I have a data set which one of the column of this data set are string and I want to extract numbers which is between two ":". However, I know the substr command which will do this operation but my problem is the numbers between two ":" have different digits. this will make my... (11 Replies)
Hi,
I wanted to create an automated script that will output a create table statement in unix. Below is the input and the desired output:
INPUT:
desc ZZ_APL_TIDDATELIST
(
TID NUMBER
AEX_DATE TIMESTAMP(6)
)
desc ZZ_APL_TIDLIST
(
TID NUMBER
)
desc... (5 Replies)
Hi,
I have a script which I need to change. I want to add a semicolon at the end of each line where the line starts with "grant"
for e.g.
create table(....
);
grant select on TABL1 to USER1
grant select on TABL1 to USER2should become
create table(....
);
grant select on TABL1 to... (3 Replies)
Hi,
I have a file in PERL in the following pattern
filename| 06-Dec-11 03.04.14.000000 PM
filename1| 06-Dec-11 05.05.14.000000 PM
I need to replace .(dot) with :(semicolon) in the timestamp value of the file
How can this be done. Any help will be appreciated
Thanks in advance (5 Replies)
Hi guys,
I want to write script so that i can put semicolon after every numeric
e.g
input would be like that
50060E80058F49A4
Output should be
50:06:0E:80:05:8F:49:A4
Please help
Thanks & Regards
Nirjhar (11 Replies)
char str; char str ;
char *ptr; char * ptr;
int CASE; int CASE;
double temp; double temp;
Output should be:
char str;
char *ptr;
int CASE;
double temp;
How can i do this with awk,sed,perl? (5 Replies)
I have a file that is formatted in this way.
a1;b2;c33;d4;e5;e;f;f;f;s
d;ds;d;a;v;b;g;gr;r;rt;fdf
s1;s2;s2;s3;s4;
b1;f2;g3;h4;a3c4e;xcsd;fds;
sd2;fs4;fs2;sdf3;
I want to replace the value just before the 4th semicolon to empty string, regardless the value, such that it looks... (3 Replies)
So, I'd like to wget a webpage, as its not going to stick around forever - but the problem is the webpage has a semicolon in it.
wget http://example.com/stuff/asdf;asdf obviously doesn't get the right webpage.
Any good way around this? (2 Replies)
The log reads as follows.
fname1;lname1;eid1;addr;pincode1;
fname2;lname2;eid2;addr2;pincode2;
fname3;lname3;eid3;addr3;pincode3;
fname4;lname4;eid;addr4;pincode4;
how do i extract only fname and save it in an array
similarly for lname and so on
i tried reading a file and cutting each... (5 Replies)