General :: How To Modify Some Particular Elements Of Column

Feb 22, 2010

It is very important for my research work. For example mydata.txt:
id type x y z
1 6 0.474611 0.227223 0.583947
2 4 0.422894 0.22726 0.536791
3 5 0.448963 0.200148 0.560336
4 3 0.386478 0.207721 0.515293
5 6 0.371617 0.22361 0.582206
6 4 0.32123 0.222999 0.534782

How to change second column (type) whose values are 4 and 3 to value 1, so that mydata.text file become:
id type x y z
1 6 0.474611 0.227223 0.583947
2 1 0.422894 0.22726 0.536791
3 5 0.448963 0.200148 0.560336
4 1 0.386478 0.207721 0.515293
5 6 0.371617 0.22361 0.582206
6 1 0.32123 0.222999 0.534782

View 6 Replies


ADVERTISEMENT

General :: Unable To Use AWK To Modify Column

Jul 28, 2011

I want to use awk to modify file like this

origin:

A[]A[][]A[]A

modified:

A[]a[][]A[]A

but when I use

awk '{$2="a"; print $0}' inputfile

the output is

A[]a[]A[]A

where the [] means space. This is not what i want. I guess that is because the OFS is one space by default, but i really don't know how to solve this.

View 11 Replies View Related

General :: Calculate 3rd Column Which Should Be Addition Of Value In 1 And 2nd Column?

Jul 19, 2010

How would i calculate following values.Initial file

10 3
20 4
How would i calculate 3rd column which should be addition of value in 1 and 2nd column.File after calculation
10 3 13
20 4 24

View 14 Replies View Related

General :: Awk Gsub() Command - String (column) Manipulation - Replace The Value Of The $1 Column In The Awk Print String?

Mar 7, 2010

i use this script to get the time and date of back and fourth transactions for a particular execution id. I use a substr command on the 5th column to to cut the milli seconds off the time value. - otherwise the times would look like 08:30:04.235

grep <executionID> <auditfile> | awk '{ print $1, $2, $3, $4, substr($5,1,8}
FIX -> Mon 3/1/2010 08:30:04
FIX <- Mon 3/1/2010 08:32:36
FIX <- Mon 3/1/2010 08:35:08

[code].....

anyhow - i append two sed commands to further clarify the direction of the message.

awk '{ print $1, $2, $3, $4, substr($5,1,8} | sed -e 's/->/ ->IN/g' | sed -e 's/<-/<-OUT/g'
FIX -> IN Mon 3/1/2010 08:30:04
FIX <- OUT Mon 3/1/2010 08:32:36

[code]....

I tried using an awk gsub () command within the string instead of the two seds, but it did not work:

awk '{ print gsub(/<regex>/, <replace with>,$1), $2, $3, $4, substr($5,1,8}

the sed works ok, but it would be cooler to make the replacement within the awk command:

gsub(/->/,-> IN, $1)

Is there a way where i could replace the value of the $1 column in the awk print string?

View 1 Replies View Related

Programming :: Awk Multiple Column Into Single Column?

Jul 15, 2010

I have a multicolumn datas, like

a1 b1 ... f1
a2 b2 ... f2
. . ... .

[code]...

I would like to make a file with all these data in one column, like

a1
a2
.
.

[code]....

Can it be done with awk or some other command? Also, is it possible then do add another column in front of this one with numbers of the lines (for every previous column), like

1 a1
2 a2
. .
. .

[code].....

View 14 Replies View Related

General :: Get Elements From List In Bash?

Mar 19, 2010

Here is a LIST:

List = "abcd 1234 jvm something"

How to get the second element "1234" without looping all the list?

View 2 Replies View Related

General :: Randomly Shuffling Of Array Elements?

Oct 10, 2010

i have an array var=(node1,node2,node3,node4) and i want to shuffle the array elements randomly every time when unix script will run like that.....

first time when script run order will be shuffle randomly
node3,node1,node4,node2

second time when script run order will be shuffle randomly like
node1,node4,node2,node3

third time when script will run again order will be shuffle randomly like
node2,node1,node3,node4

how to do this without using of shuf or shufsequence commands

View 8 Replies View Related

General :: When Running Echinus Can Scrollbars And Similar Window Elements Be Skinned?

Apr 22, 2011

I see on the website URl...screenshots number 5 and 6 -- what is used to to get these style of scrollbars? When I launch Opera I get a very ugly scrollbar that does not fit the look of the wm whatsoever.

View 1 Replies View Related

General :: Insert Column With Awk / Sed Between Two?

Jan 18, 2011

I have a two column file and I need to create a new column in between the first and second but the new column adds a value to the first. E.g.code...

I thought I had figured out how to do it with the following but it just hangs:

awk -F '{print $0,$0+25,$1}' file_in > file_out

Also tried the following to no avail:

awk -F,-v OFS,'{print $0,$0+25,$1}' file_in > file_out

I can add the new column with the added value to the last column easy ( awk '{print $0,$0+25}' file_in > file_out).

View 8 Replies View Related

General :: First Column Of Vim Highlighted Yellow And Won't Go Away?

Feb 23, 2011

I have not defined a user vimrc, OS is redhat 4.6 and after a search and replace the first column in the editor is highlighted yellow and it stays that way as I close and open vim. This is the /etc/vimrc that came on the system. anyone see a bug or a reason it would do that?

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)

[Code]....

View 2 Replies View Related

General :: LS And OD Command - First Column Will Be Always 000000

Oct 20, 2010

1. when we run od command it displays octal values. But the first column will be always 000000. after that the actual file contents are displayed. Can anyone tell the meaning of that.

2. When we run ls -l command, in the first line of the output, we can see some integer value. What is the significance of that value.

View 4 Replies View Related

General :: File Name In Separate Column?

Apr 26, 2010

I have some series of files, which actually named bellow

<day_month_yr>_<hh:mm:ss>.<host_name>.<IP.ip.ip.ip>.<log_name>.txt

I want to show this file name below the column may be

Date Time Host_Name IP_address Login_Name
----- ---- --------- ---------- ----------
<day_month_yr> <hh:mm:ss> host_name x.x.x.x log_name
...

View 5 Replies View Related

General :: Use Awk To Matching In Only A Specific Column?

Jul 12, 2010

Im trying to use awk to do matching in only a specific column

example.txt:
www.google.com www.example.com
www.google.com/search www.example2.com
i used:
awk '{ (if $1 == "http://www.google.com") print $2}' example.txt

this awk statement only returns the first line, and i cant seems to make it perform in a way to match based on keywords like GREP. Is there any way to make display the other lines which contains "google" also?

View 1 Replies View Related

General :: Unable To Extract Last Column From Awk

May 20, 2011

I have a basic question of awk.

Code:

var=/test/build/create/sls
echo $var | awk '{ FS = ":" ; print $NF }'
/test/build/create/sls

I am trying to extract last column from the above awk one liner.

View 4 Replies View Related

General :: Replacing Character / Value In Certain Column

Jun 21, 2011

I need to replace a value in a file. For example the content of data.txt file is:
1 1 23
2 1 42
3 2 52
4 2 62
5 1 77
6 1 88
7 2 99
8 1 100

Could I substitute 2 in second column with 3 using awk and or sed or other command so that the data will be change as follow?
1 1 23
2 1 42
3 3 52
4 3 62
5 1 77
6 1 88
7 3 99
8 1 100

View 3 Replies View Related

General :: How Do I Sort Output Of Du By Its First Column

Mar 30, 2010

How do I sort the output of du by its first column. I issue the command this way:$ du.Is there a way?

View 5 Replies View Related

General :: Blocks Column In Edquota Output?

Aug 28, 2010

I know what are hard and soft limits, but what means "blocks" column in edquota utility?

View 1 Replies View Related

General :: Extract 5th Column From A File Without The Header?

Oct 15, 2010

How can I extract 5th column from a file without the header.

View 5 Replies View Related

General :: Ubuntu 10.10 - How To Highlight And Copy Column

Nov 23, 2010

Ubuntu 10.10
Gnome desktop
On a text file, .txt, it is possible to high-light and copy a row on a table. But how to high-light and copy a column.

View 14 Replies View Related

General :: How To Redirect The Output To Different Column In .csv File?

Apr 25, 2011

I was trying to redirect the output of two variables to different columns of a .csv file in MS excel like this,

Code:
echo "$a $b" > abc.csv
But I am getting both $a and $b in the same column, is there anything I can use instead of to move the value of $b to the next column? Or is there a good different approach to do it?

View 2 Replies View Related

General :: Insert (Same Template Strings) Column With VI

Jun 24, 2011

I have this piece of code with some template strings.

Code:
Big_L: $Big_L
$Big_R
$Lambda_tf
$Epsilon_1
$mu
$n_0
$ms
$Delta_R
$Epsilon_2
$Lambda_d
$Epsilon_3
$Small_N
$Small_Q

How can I insert exactly the same template strings in front of each string, but just without the '$' sign (see the first line for an example)?

View 7 Replies View Related

General :: Column Manipulation In Bash Script

Mar 19, 2010

I have a text file and I need to replace the 3rd column of that file from row 3 to the end of the file with a column which I have stored in the different text file. For e.g the original file is like given below:

a.txt nobla 6 gadf 72.500 1.600 1.800 .850 5.250 8.540
A# rad ang ht prf bk sd dia type blade
1 0.3081 9.00 1.9235 -17.50 18.00 -3.00 0.6250 1613 1
2 0.6509 194.00 2.0316 -17.50 18.00 -3.00 0.6250 1613 4
3 1.0128 8.00 2.1457 -17.50 18.00 -3.00 0.6250 1616 1
4 1.3748 192.00 2.2598 -17.50 18.00 -3.00 0.6250 1616 4
5 1.6986 7.00 2.3619 -17.50 18.00 -3.00 0.6250 1616 1
6 1.9347 120.00 2.4364 -17.51 18.00 -3.00 0.6250 1616 5
7 2.1327 190.00 2.4988 -17.34 18.00 -3.00 0.6250 1616 4

So lets say I wanna replace column 3 from row 3 to row 7 with a data from another file which is given below:
54.00
239.00
53.00
237.00
52.00
165.00
235.0

So the final output file should be like this:
a.txt nobla 6 gadf 72.500 1.600 1.800 .850 5.250 8.540
A# rad ang ht prf bk sd dia type blade
1 0.3081 54.00 1.9235 -17.50 18.00 -3.00 0.6250 1613 1
2 0.6509 239.00 2.0316 -17.50 18.00 -3.00 0.6250 1613 4
3 1.0128 53.00 2.1457 -17.50 18.00 -3.00 0.6250 1616 1
4 1.3748 237.00 2.2598 -17.50 18.00 -3.00 0.6250 1616 4
5 1.6986 52.00 2.3619 -17.50 18.00 -3.00 0.6250 1616 1
6 1.9347 165.00 2.4364 -17.51 18.00 -3.00 0.6250 1616 5
7 2.1327 235.00 2.4988 -17.34 18.00 -3.00 0.6250 1616 4

And I will post the code whatever i have tried soon. I started with awk and cut commands..but never got it to work and also tried PASTE command too.

View 3 Replies View Related

General :: Extract One Complete Column From LS Output

Oct 2, 2010

What I need to do is to extract one complete column (file size) from the output of ls -lS but while doing so in some rows I have a single space but in some other rows I have 2 or 3 spaces like some file sizes are different with 30 bytes 400 bytes and some 4000 bytes. So when I extract the output of ls using | cut -d ' ' -f5 i get the value which has only one space i.e. I get 4000 as output because 400 has 2 spaces seperated and 30 is 3 spaces separated. So how to get the file size column from the ls output?

View 10 Replies View Related

General :: Sort The 3rd Column In A Table Numerically

Jun 22, 2010

i wanna sort the 3rd column in a table numerically ( no actual borders...only tabs seperating the columns)
it should be something like this but i cant get it right

Sort -u +1 -3 results

the file is called results

View 7 Replies View Related

General :: Sorting A First Non-numerical Column In A File?

Jul 13, 2011

I have a file like:

ER- V67
ER+ V68
ER- V69
ER+ V70

[Code]....

I am using the code:

sort -k1

but it prints it by sorting the second column.

View 8 Replies View Related

General :: Text File Column Editing

Jul 17, 2011

I have 2 large text files , one looks like this:

<contact type="1">blahblah@hotmail.com</contact>
<contact type="1">blahblah2@hotmail.com</contact>
<contact type="1">blahblah3@hotmail.com</contact>

The other is a list of emails in single column format like this:

emailaddy@hotmail.com
emailaddy2@hotmail.com
emailaddy3@hotmail.com , etc

Is there a command to delete all the blahblah emails from text file 1 and replace them with the ones from text file 2?

Or maybe a linux version of 'Csved' which has the ability to add,remove,insert columns?

View 5 Replies View Related

General :: Convert Irregular Lines Into Formatted Column Using Awk?

Apr 17, 2010

I'm newbie to awk scripting. Need your great help to convert the irregular lines into column using awk (Sorting based on "Pri Number" column)

Input files is as follows:

Partition Name OA
Partition UID: 88:93:22:AE:B3:42:DF:11:A8:64:00:60:16:36:04:02
HBA/SP Pairs:

[Code]...

View 2 Replies View Related

General :: Combine Two Files Column-wise In Ubuntu?

Jul 7, 2011

I have two files: one is like

preface
Introduction
chapter 1
the other is like
1
2
3

I was wondering how to column-wise combine the two files into one:

preface 1
Introduction 2
chapter 1 3

by using some utilities, such as awk, sed, available in Ubuntu?

View 1 Replies View Related

General :: Recreating A Column Byte-based File?

Nov 5, 2009

I have a file that stores employee login IDs, names, types, and permissions. Our software reads the information based on byte-columns, so it reads a column as any ASCII character (spaces, letters, numbers, punctuation, etc.). I want to create a web-interface for adding and removing users, and storing the data in a MySQL database. However, if I am creating the files from the MySQL output, I need a way to write to specific column locations in the file ...

User ID: Columns 1-4
User Name: Columns 6-30
Type: 32-40
Permissions: 42-45

I want to use a scripting language, preferably C-Shell, to call MySQL for the data and write the data to the correct columns of the file. I wrote a script that takes the data from the file, and dumps it into the MySQL table, so maybe I can pad the remaining space in the table column to fill with spaces ...

View 12 Replies View Related

General :: Delete Rows Based On Values In A Column Using Sed?

Jan 18, 2011

I have a lot of files with thousands of rows and usually two columns of data. Column 1 is a coordinate, column 2 is a score. I want to delete rows that have a value in column 2 over, in this case, 50.

For example, here's a clip from a file:

2999898 39
2999899 40.9
2999900 42.7
2999901 44.7
2999902 46.7
2999903 48.9
2999904 51.1
2999905 53.3
2999906 55.7

I want the output to be this:

2999904 51.1
2999905 53.3
2999906 55.7

I know how to use sed for very basic things like deleting rows or ranges of rows but I can't figure out this ostensibly easy command.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved