Sponsored Content
Full Discussion: problem with awk usage
Top Forums Shell Programming and Scripting problem with awk usage Post 302411673 by sugan on Friday 9th of April 2010 07:09:09 AM
Old 04-09-2010
The output in the tmp file should be the same with the 4th feild changed. I am using sed to replace the existing line with the new line. When the new line has dates in the format 'yyyy/mm/dd' sed throws error.

Here is my code:
Code:
 elif [ $1 != 'Cindy' -a  `echo $Line | grep -ce 'Larry' -e 'Joe' -e 'Bryan' -e 'Lane'` -gt 0 ]
    then
      NEW_LINE=`echo $Line | awk '{sub ($4, "2010\\\/04\\\/07"); printf "# %-7s %9s %18s\n", $2,$3,$4} {$1=$2=$3=$4=""; sub("   ",""); print}'`
      sed $n" s/.*/$NEW_LINE/" kfile > tmp
      mv tmp kfile
    fi

Here is the error msg I get:
Code:
sed: 0602-404 Function 167 s/.*/# seh          Lane       2010\/04\/07 retrieve 0 rows from US FIW on 2009/06/11/ cannot be parsed.

In the above code, when the new line has dates in the format 'yyyy/mm/dd' after 4th feild, I have a problem with sed.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

AIX disk usage problem

ENV: AIX 4.3 / rs6000 while running a program our root (/) directory fills up. I simply can't find where this file is located. Doing a df . insite the program gives the following output: during run of program /dev/hd4 65536 33144 50% 953 6% / after run of program... (1 Reply)
Discussion started by: progressdll
1 Replies

2. AIX

Netstat usage problem

Hi everyone. I need some way to map individual connections listed in netstat to PID seen by the AIX. In linux this can be done by using netstat -np. Is there a swich in AIX netstat which I have not yet found regarding this or does anyone know if "GNU" netstat has been compiled for AIX in... (1 Reply)
Discussion started by: sprellari
1 Replies

3. Programming

Problem in CPU usage

Hi all, I have C++ program that is running on linux on an ARM processor. The program is sending voice to a specific ip. When i started the program, 2 threads are running and sending voice over ip. Each of the threads are at %0.2 CPU usage which is very normal. My problem is, CPU usage is... (4 Replies)
Discussion started by: gokaytos
4 Replies

4. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

5. Shell Programming and Scripting

usage of underscore in awk

Hi what is the purpose of using underscore in awk. I suppose it is for defining macro's and reducing repeatation but can some one show me an example? (6 Replies)
Discussion started by: ahmedwaseem2000
6 Replies

6. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

7. Shell Programming and Scripting

Problem in file usage option

Hi, I have a dout in -u option in ls command. If we give ls -lt command it will dispaly the last modfied time. If we give ls -lu command it will display the last usage time of the file. My doubt here is Please refer the below commands. /appldata/rsc/dm/RejectData$ls -lt... (6 Replies)
Discussion started by: puni
6 Replies

8. UNIX for Dummies Questions & Answers

awk FS usage problem

Hi All, I have a question about the usage of FS in awk and i appreciate if you can help me sort out what i'm doing wrong. I have a file with info ; separated and i just want to print the o/p of all fields ($1 -> $8) to the screen. As you can see it is very simple but i'm facing an error. ... (5 Replies)
Discussion started by: Dendany83
5 Replies

9. Shell Programming and Scripting

Usage of Int with NR in awk

Hello Everyone, I am new to awk and trying my hand with the diff codes and came across the below code today. It would be great if any of the Guru's help me to understand. awk '{filename = "sample_file" int((NR-1)/34) ".DAT"; print >> filename}' sample_file.DAT 34 is the no of lines each... (7 Replies)
Discussion started by: saratha14
7 Replies

10. Shell Programming and Scripting

awk usage

Hi I have a file like this user="joe" phone="4280919" duration=128 login=12/02/2016 ip-address=10.230.120.35 user="mary" phone="6352728" duration=23 login=16/02/2016 ip-address=10.123.231.54 I have to convert these to as follows (csv format) (Ignore Login field)... (6 Replies)
Discussion started by: Balav
6 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWgawk | +--------------------+-----------------+ |Interface Stability | Volatile | +--------------------+-----------------+ NOTES
Source for gawk is available on http://opensolaris.org. Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 04:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy