There is no need for cat in this pipeline and there is no need for two of your three invocations of awk.
There is no occurrence of the string +2 in your sample input and there is nothing wrong with your calculation as long as the leading character in hour field in your input file is a plus sign. But, your calculation would be wrong if the leading character in that field was a minus sign (which does not appear in your sample input). If we assume that the 1st character in the hour field will ALWAYS either be a plus sign (+) or a minus sign (-), the following seems to do what I would guess you were trying to do:
If we add a couple of timestamps with negative hours to your sample maser_neg_test.txt for testing:
the above code produces the following output in maser_neg_test2.txt:
which I assume is appropriate output for that input.
can anyone help me how do i add the colums using awk seperated by character @. for eg i have
3@4
2@9
5@1
the result should be
10 14
i tried using
{ sum+= $1 }
END { print sum }
but it just gives the result 10. can anyone help me with this one
thank you and best regards (7 Replies)
Hi,
How to format something like this:
John Roberts 324-141-984 Acct
Jack Williams 159-555-555 Acct
William Jackson 949-911-888 Acct
Mark J Walton 145-852-252 Acct
Fred P Milton 483-244-390 Acct
Bill P J Miller 404-050-223 Acct
into... (12 Replies)
hello
cant find a way to make something like:
awk '{print $1 - $5}' somefile
which is printing $1 $2 $3 $4 $5
should make an array or something? i just dont wanna write $1 $2 $3 $4 $5 to awk input i need to use from $1 to $5 and print them all
and then i need to swith to: from $6 to $10 (3 Replies)
How can I use awk to create a new file that has 2 columns, each colums comes form a different file.
example:
I need column 3 from file1 and column 5 from file2 to make file3. (3 Replies)
I have a data file with 4 columns, of the format:
A1 A2 A3 A4
B1 B2 B3 B4
C1 C2 C3 C4
etc..
I would like to insert to put column 2,3,4 on a new line so my new format would be:
A1
A2 A3 A4
B1
B2 B3 B4
C1
C2 C3 C4
etc.
but am new at using AWK and am not sure how to do it. (5 Replies)
HI ,
I have a comma delimiter file, in which I want to remove 8th and 9th column.
I tried removing those columns using the below code
awk 'BEGIN { FS=","; OFS="," } {$8=$9="";gsub(",+",",",$0)}1' infile
But the problem is 8th and 9th columns are user entered fields, theyvhave carriage... (1 Reply)
Hi experts,
I've used several solutions from this forum to delete nonsense and rearrange data in the project file I'm working on. I'm hoping you guys can give me some tips on further rearranging the data (I've seen a few solutions by searching, but one specific item has me stumped, which is only... (5 Replies)
Hi,
I am making a shell script in bash which uses gnuplot to plot the number of road accidents on a certain day, on a certain month. I believe I have the data correct. An example of my data file is here:
cat Day1Accidents.txt
01 13
02 5
03 17
04 8
05 16
06 18
07 12
08 7
09 23
10 12... (2 Replies)
Hello everyone
I am a beginner in Shell scripting. Need your help to achieve desired result.
I have a file (sample format below)
001g8aX0007jxLz xxxxxxxxxxxxxxx 9213974926411 CO-COMM-133 CO-L001-DLY 7769995578239 44938 1 1
... (1 Reply)
Hi,
I'm trying to copy and paste the sixth column from a bunch of files into a single file having each column pasted in separate columns (and not one after each other in just one column.)
I tried this code but works only partially because it copied and pasted 50 rows of each column... (6 Replies)
Discussion started by: Frastra
6 Replies
LEARN ABOUT NETBSD
column
COLUMN(1) BSD General Commands Manual COLUMN(1)NAME
column -- columnate lists
SYNOPSIS
column [-tx] [-c columns] [-s sep] [file ...]
DESCRIPTION
The column utility formats its input into multiple columns. Rows are filled before columns. Input is taken from file operands, or, by
default, from the standard input. Empty lines are ignored.
The options are as follows:
-c Output is formatted for a display columns wide.
-s Specify a set of characters to be used to delimit columns for the -t option.
-t Determine the number of columns the input contains and create a table. Columns are delimited with whitespace, by default, or with
the characters supplied using the -s option. Useful for pretty-printing displays.
-x Fill columns before filling rows.
column exits 0 on success, >0 if an error occurred.
ENVIRONMENT
COLUMNS The environment variable COLUMNS is used to determine the size of the screen if no other information is available.
EXAMPLES
(echo "PERM LINKS OWNER GROUP SIZE MONTH DAY HH:MM/YEAR NAME";
ls -l | sed 1d) | column -t
SEE ALSO colrm(1), ls(1), paste(1), sort(1)HISTORY
The column command appeared in 4.3BSD-Reno.
BSD March 9, 2008 BSD