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
i appreciate input, I have tried both, however nothing is incremented in the finished file, and there are no errors -- what do you think may be the problem??
I waited until the awk solutions were working for the OP to avoid confusing the issue. I think awk is best for this kind of task. The language may look odd at first, but it allows solutions that are flexible, powerful, and succinct However, if |stat routines are required, here is how it might look:
#!/usr/bin/env bash
# @(#) s1 Demonstrate manipulation with |stat dm.
echo
set +o nounset
LC_ALL=C ; LANG=C ; export LC_ALL LANG
echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG"
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version "=o" $(_eat $0 $1) dm
set -o nounset
echo
FILE=${1-data1}
echo " Data file $FILE:"
cat $FILE
echo
echo " Results:"
dm x1 "if x1 = 0 then x2+1 else x2" < $FILE
exit 0
Producing:
% ./s1
Environment: LC_ALL = C, LANG = C
(Versions displayed with local utility "version")
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution : Debian GNU/Linux 5.0
GNU bash 3.2.39
dm - (local: ~/executable/dm Nov 9 16:22 )
Data file data1:
2 21
1 12
3 123
4 1234
6 49
0 49
33 212
Results:
2 21
1 12
3 123
4 1234
6 49
0 50
33 212
This was done using the information in man dm. If the earlier awk solutions (involving bang [!]) were to be placed in a Bourne shell family script (sh, bash, zsh), the troubles may not have occurred. I use tcsh a lot for interactive work, but very rarely for scripting, hence I would not have written the command interactively, but I would have placed it in a script -- anything used more than twice, takes arguments, or is "long", I place into a script.
Knowing more than one approach is often useful, and is the heart of *nix systems ... cheers, drl