11-10-2015
Hi Amit,
what does awk -v stands for it.?
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have file with multiple columns. Column values for a record may be same.
Now i have to replace a column value(this can be same for the other columns) with new value.
File.txt
A,B,C,D,A,B,C,D,A,B,C,D
A,B,C,D,A,B,C,D,A,B,C,D
A,B,C,D,A,B,C,D,A,B,C,D
A,B,C,D,A,B,C,D,A,B,C,D... (1 Reply)
Discussion started by: ksailesh
1 Replies
2. UNIX for Dummies Questions & Answers
Hi
I am looking for a particular string in a file.If the string exists, then I want to replace another string with some other text.Once replaced, search for the same text after that character position in the file. :wall:
E.g: Actual File content:
Hello
Name: Nitin Raj
Welcome to Unix... (4 Replies)
Discussion started by: dashing201
4 Replies
3. Shell Programming and Scripting
Hi,
I need some unix command to replace the following thing.
cat test.dat
1234|test|8/19/2009|8/20/2009|test
1234|test|8/9/2009|8/21/2009|test
1234|test|8/1/2009|8/2/2009|test
after processing
1234|test|08/19/2009|08/20/2009|test
1234|test|08/09/2009|08/21/2009|test... (6 Replies)
Discussion started by: anshaa
6 Replies
4. Shell Programming and Scripting
I need to be able to search for a string in the first column and if that string exists than replace the nth column with "-9.99".
AW12000012012 2.38 1.51 3.01 1.66 0.90 0.91 1.22 0.82 0.57 1.67 2.31 3.63 0.00
AW12000012013 1.52 0.90 1.20 1.34 1.21 0.67 ... (14 Replies)
Discussion started by: ncwxpanther
14 Replies
5. Shell Programming and Scripting
how to search and replace string in column in file with command sed or other
search "INC0000003.in" and replace column 4 = "W"
$ cat file.txt
INC0000001.in|20150120|Y|N|N
INC0000002.in|20150120|Y|N|N
INC0000003.in|20150120|Y|N|N
INC0000004.in|20150120|Y|N|Noutput... (4 Replies)
Discussion started by: ppmanja3
4 Replies
6. UNIX for Dummies Questions & Answers
Hi Everyone,
I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file.
I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies
7. Shell Programming and Scripting
I am passing a variable and replace nth value with the variable.
I tried using many options in awk command but unable to ignore the special characters in the output and also unable to pass the actual value.
Input : "1","2","3"
Output : "1","1000","3"
TempVal=`echo 1000`
Cat... (2 Replies)
Discussion started by: onesuri
2 Replies
8. Shell Programming and Scripting
Hi,
I have a text file which looks like this
a.txt
A,12,Apple,Red
B,33,Banana,Yellow
C,66,Sky,Blue
I need to search for a particular field(s) in particular column(s) and for that matching line need to replace the nth column.
Sample scenario 1:
Search for 66 in second field and Sky in... (5 Replies)
Discussion started by: wahi80
5 Replies
9. Shell Programming and Scripting
Hello All,
I am writing a shell script with following requirement:
1. I have one input file as below
CHE01,A,MSC,INO
CHE02,B,NST,INC
CHE03,C,STM,INP
2. In shell script I have predefined array as below:
Array1={A, B, C}
Array2= {U09, C04, A054} (6 Replies)
Discussion started by: angshuman
6 Replies
10. UNIX for Beginners Questions & Answers
I have the below string which i need to compare with a file and replace this string in the file which matches closely. Can anyone help me on this.
string(Scenario 1)- user::r--,user::ourfrd:r--
String(Scenario 2)- user::r--
File
****
# file: /local/Desktop/myfile
# owner: me
# group:... (6 Replies)
Discussion started by: sarathy_a35
6 Replies
LEARN ABOUT DEBIAN
numsum
NUMSUM(1) User Contributed Perl Documentation NUMSUM(1)
NAME
numsum - numsum program file
SYNOPSIS
numsum [-iIcdhrsvxy] <FILE>
| numsum [-iIcdhrsvxy] (Input on STDIN from pipeline.)
numsum [-iIcdhrsvxy] (Input on STDIN. Use Ctrl-D to stop.)
DESCRIPTION
numsum will take all the numbers on stdin and return the sum of those numbers. Currently it only processes the first number on each line.
Besides positive numbers, it also handles negative numbers and numbers with decimals.
OPTIONS
-i Only return the integer portion of the final sum.
-I Only return the decimal portion of the final sum.
-c Print out the sum of each column.
-r Print out the sum of each row.
-x <n> Specify a comma seperated list of columns to print.
-y <n> Specify a comma seperated list of rows to print.
-s <string> Specify a string to use as a seperator for columns.
This defaults to be consecutive whitespace (s+).
-h Help: You're looking at it.
-V Increase verbosity.
-d Debug mode. For developers
-q Quiet mode, don't print any warnings.
EXAMPLES
Simply add up the numbers in a file.
$ numsum numbers.txt
4315
Enter your own numbers on STDIN. The last number is the answer.
$ numsum
4
21
98
100
223
Use it in a command pipeline.
$ ls -1s | grep .mp3 | numsum -c -x 5
72288
Add up the total byte count in a http log file.
$ cat access_log | awk {'print $10'} numsum
or
numsum -c -x 10 access_log
Add up the columns of numbers of a file.
$ cat columns
1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25
$ numsum -c columns
15 40 65 90 115
Add up the 1st, 2nd and 5th columns only.
$ numsum -c -x 1,2,5 columns
15 40 115
Add up the rows of numbers of a file.
$ numsum -r columns
55
60
65
70
75
Add up the 2nd and 4th rows.
$ numsum -r -y 2,4 columns
60
70
SEE ALSO
numaverage(1), numbound(1), numinterval(1), numnormalize(1), numgrep(1), numprocess(1), numrandom(1), numrange(1), numround(1)
COPYRIGHT
numsum is part of the num-utils package, which is copyrighted by Suso Banderas and released under the GPL license. Please read the COPYING
and LICENSE files that came with the num-utils package
Developers can read the GOALS file and contact me about providing
submitions or help for the project.
MORE INFO
More info on numsum can be found at:
http://suso.suso.org/programs/num-utils/
perl v5.10.1 2009-10-31 NUMSUM(1)