I am trying to swap 2 columns in a specific block of a file. The file format is:
I am trying to
1) replace 5th column with 2nd column.
1-1) If a letter in 5th column is "r", this would be replaced with "v". If a letter in 5th column is "f", this would be replaced with "^".
2) insert two double quotation marks in 1st column.
3) replace 3rd column with ;
4) replace 4th column with //
This should only be done in blocks which are defined starting and ending lines - "input external delay" , "data arrival time".
Additionally, I want to change texts before/after the block with predefined texts. Before the block, I would like to add $path {
// from: in11
// to: out432
$name "test_1" ;
$cycle 1 ;
$slack -0.130978 ;
$transition {
After the block, I would like to add }
}
My expected output should be:
Currently, I can swap columns, but I don't know how to use them only in the block. My code is:
Any help you could give me will be greatly appreciated.
Following may help you in same.
Output will be as follows. EDIT: Adding a non one-liner form for same solution too now.
Output will be as follows.
Thanks,
R. Singh
Last edited by RavinderSingh13; 12-31-2015 at 04:25 PM..
Reason: Added a non one-liner form for solution now.
Hi Experts,
I have a problem where I want to print missing columns (3,4) within a block of text. Each block is separated by "###". Some rows have missing column 3 and 4 which should be same as the previous value in column 3 and 4. The file is space delimited.
For example:
INPUT
###... (5 Replies)
Hi
I have a file which is tab-delimited. Now, I'd like to print the lines which have "chr6" string in both first and second columns. Could anybody help? (3 Replies)
Hello,
Searched for a while and found some "line-to-column" script. My case is similar but with multiple fields each row:
S02 Length Per
S02 7043 3.864
S02 54477 29.89
S02 104841 57.52
S03 Length Per
S03 1150 0.835
S03 1321 0.96
S03 ... (9 Replies)
I am trying to find a specific set of characters in a long file. I only want to find the characters in column 265 for 4 bytes.
Is there a search for that? I tried cut but couldn't get it to work.
Ex. I want to find '9999' in column 265 for 4 bytes. If it is in there, I want it to print... (12 Replies)
Hi,
I'd like to swap the columns 1 and 2 of a space-delimited text file but only for the first 1000 rows. How do I go about doing that? Thanks! (1 Reply)
Hi,
I have a file containing multiple entries. Each block starts with <BEGIN and ends with <END. Sample data is given below
<BEGIN
IMSI=095001202630;
MSISDN=00145132916;
DEFCALL=TS11;
CURRENTNAM=BOTH;
CAT=COMMON;
TBS=TS11&TS12&TS21&TS22;
CARDTYPE=SIM;
... (2 Replies)
Hi!
Im trying to swap 2 columns in a file.The file format is:
'ColumnA','ColumnB'
'A1','A2'
'B1','B2'
'C1','C2'
I tried to solve this using AWK, when I run this command:
awk 'BEGIN {FS=OFS=","} {temp=$1; $1=$2; $2=temp} {print}' InFile.csv >> Outfile.csv
What I get is this:
... (5 Replies)
Hello,
I have a file like this:
FILE.TXT:
(define argc :: int)
(assert ( > argc 1))
(assert ( = argc 1))
<check>
#
(define c :: float)
(assert ( > c 0))
(assert ( = c 0))
<check>
#
now, i want to separate each block('#' is the delimeter), make them separate files, and then send them as... (5 Replies)
I'm Unix. I'm looking at "df" on Unix now and below is an example. It's lists the filesystems out in 512-blocks, I need this in 4k blocks. Is there a way to do this in Unix or do I manually convert and how?
So for container 1 there is 7,340,032 in size in 512-blocks. What would the 4k block be... (2 Replies)
I have a input file that has some common values in 1st,2nd and 3rd columns. 4th and 5th are different. Now I would like to print the mean of the fourth column of similar values in 1st.2nd and 3rd columns along with all the values in 5th column.
input
NM_0 1.22 CR5 0.4 n_21663... (10 Replies)