Sponsored Content
Top Forums Shell Programming and Scripting Unix c-shell - replacing/incrementing values in columns? Post 302370092 by audrey_flox on Tuesday 10th of November 2009 10:49:58 AM
Old 11-10-2009
thank you for you input.
i tried awk '!$1{$2+=1}1', however it gives me a bunch of errors. problem is that can not decipher the syntax of this awk expression for successful debugging. would you mind clarifying?

paste num.txt num2.txt | awk '!$1{$2+=1}1'

output in terminal:
paste num.txt num2.txt | awk 'num2.txt1{$2+=1}1'
awk: syntax error at source line 1
context is
>>> num2 <<< .txt1{$2+=1}1
awk: bailing out at source line 1


thank you!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing word and Incrementing

Hi I'm having difficulty in writing a script with searching a specified word using sed and replaces that word with numbers that is incremented I tried this: #!/bin/sh awk '{ for (i=2010; i<=NF; i++) sed 's/TBA/$i; }' filename.txt > outputfile.txt but it doesn't work. here is my desired... (1 Reply)
Discussion started by: sexyTrojan
1 Replies

2. Shell Programming and Scripting

Incrementing ascii values

Hi All, I require some help with the below: I am trying to incriment the ascii value of a letter and then print it. So basically "a" becomes "b" and "z" becomes "A". Does anyone have any pointers? Cheers, Parks (10 Replies)
Discussion started by: bParks
10 Replies

3. UNIX for Dummies Questions & Answers

Removing columns from a text file that do not have any values in second and third columns

I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns: 4 0.04972604 KLHL28 4 0.0497332 CSTB 4 0.04979822 AIF1 4 0.04983331 DECR2 4 0.04990344 KATNB1 4 4 4 4 How can I remove the trailing... (3 Replies)
Discussion started by: evelibertine
3 Replies

4. Shell Programming and Scripting

Auto incrementing a particular column values

Hi All, I have the input file(.csv) like below. SNo,Step,Data 1,0,1 2,0,2 3,1,1 4,2,2 5,0,3 6,0,4 and I need the following output. 1,0,1 2,0,2 3,1,1 4,2,2 5,3,3 6,3,4 (5 Replies)
Discussion started by: ks_reddy
5 Replies

5. Shell Programming and Scripting

Sum up values of columns in 4 files using shell script

I am new to shell script.I have records like below in 4 different files which have about 10000 records each, all records unique and sorted based on column 2. 1 2 3 4 5 6 --------------------------- SR|1010478|000044590|1|0|0| SR|1014759|000105790|1|0|0| SR|1016609|000108901|1|0|0|... (2 Replies)
Discussion started by: reach.sree@gmai
2 Replies

6. UNIX for Dummies Questions & Answers

Getting values of 2 columns from sql query in UNIX variables

Hi, I have connected to oracle database with sqlplus -s / <<EOF select ename, age from emp where empid=1234; EOF I want to save the values of ename and age in unix shell variables. Any pointers would be welcome.. Thanks in advance!!1 Cheers :):):):) (1 Reply)
Discussion started by: gonchusirsa
1 Replies

7. Shell Programming and Scripting

Replacing string by incrementing number

Dear all Say I have a file as ! TICKET NBR : 234 !GSI : 102 ! 3100.2.112.1 11/06/2013 15:56:29 ! 3100.2.22.3 98 ! 3100.2.134.2 8 ! ! TICKET NBR : 1809 ! GSI : 102 ! 3100.2.112.1 11/06/2013 16:00:45 ! 3100.2.22.3 65 ! 3100.2.134.2 3 ! ! TICKET NBR : 587 ! GSI : 102 ! 3100.2.112.1... (3 Replies)
Discussion started by: OTNA
3 Replies

8. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

9. Shell Programming and Scripting

Help with shell script: selecting rows that have the same values in two columns

Hello, everyone I am beginner for shell programming. I want to print all lines that have the same values in first two columns data: a b 1 2 a a 3 4 b b 5 6 a b 4 6 what I expected is : a a 3 4 b b 5 6 but I searched for one hour in... (2 Replies)
Discussion started by: nengcheng
2 Replies

10. UNIX for Beginners Questions & Answers

UNIX replacing and incrementing number

Hi I am unix newbie looking for a unix bash script that can make it easier to do my code work. we have a code number for each code block that we want to incrementally assign. We have 10000 of these and it is very laborious to do this one by one. so what we want is start from the top of the... (4 Replies)
Discussion started by: chamajid
4 Replies
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. ENVIRONMENT
The COLUMNS, LANG, LC_ALL and LC_CTYPE environment variables affect the execution of column as described in environ(7). EXIT STATUS
The column utility exits 0 on success, and >0 if an error occurs. EXAMPLES
(printf "PERM LINKS OWNER GROUP SIZE MONTH DAY " ; printf "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. BUGS
Input lines are limited to LINE_MAX (2048) bytes in length. BSD
July 29, 2004 BSD
All times are GMT -4. The time now is 10:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy