Sponsored Content
Top Forums UNIX for Advanced & Expert Users formatting textfile inside ksh script using awk not working Post 302124462 by kamitsin on Sunday 1st of July 2007 03:56:52 AM
Old 07-01-2007
Quote:
awk -F":" '{ print $1 "\t" $2 "\t" $3 }' msgfile.txt

should be,

Code:
awk -F"," '{ print $1 "\t" $2 "\t" $3 }' msgfile.txt

because the columns are seperated by a comma.

Output:

Quote:
Firstname1 Lastname1 Initial
Firstname2 Lastname2 Initial2
Firstname3 Lastname3 Initial3
Firstname4 Lastname4 Initial4
Firstname5 Lastname5 Initial5
kamitsin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

expr inside a ksh script Solaris

Hi; If I do something like this. dftotalsize=0;export dftotalsize;df -k | grep \/db001 | awk '{print $4}' | while read theinput \ ; do export $theinput; dftotalsize=`expr $dftotalsize + $theinput`; export dftotalsize; echo $dftotalsize; done ; echo `expr $dftotalsize \/ 1024 \/ 1024 "GB" Is... (4 Replies)
Discussion started by: myjess
4 Replies

2. Shell Programming and Scripting

Getting cntrl-c entered inside a ksh script

hi guys, my ksh script is calling another script. The other script expects user to press CNTR-C, and does not return to the prompt. in my script, I want to call the other script, but somehow don't want it to wait forever, I want to return to my script. e.g. script2.ksh outputs: "No... (2 Replies)
Discussion started by: JamesByars
2 Replies

3. Shell Programming and Scripting

How to call an sql script inside a while statement in KSH

Hi all, I'm trying to run an sql inside a loop which looks like this #!bin/ksh while IFS=, read var1 var2 do sqlplus -s ${USERNAME}/${PASSWORD}@${ORACLE_SID} << EOF insert into ${TABLE} ( appt_date ) values ( '${var1 }' ); ... (6 Replies)
Discussion started by: ryukishin_17
6 Replies

4. Shell Programming and Scripting

expect script inside shell script not working.

Shell Scipt: temp.sh su - <$username> expect pass.exp Expect script: pass.exp #!/usr/bin/expect -f # Login ####################### expect "Password: " send "<$password>\r" it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Discussion started by: bhavesh.sapra
2 Replies

5. Shell Programming and Scripting

Formatting output using awk in ksh

:oi was trying to write a script to format output of a command in ksh which has output as below: so i used : to get which i require at all times. But problem occurs when status part changes. above output i get when status is SU (success).If the status is IN (inactive), output of... (1 Reply)
Discussion started by: pr5439
1 Replies

6. Ubuntu

Top output to textfile not working in cronjob

Hello, If i run the following script from the cmdline it works just fine however if i run it via root cronjob it doesn't write to the file at all. It is chmod 777 now so shouldnt be any right issues. Shellscript looks like this: /usr/bin/top -b -n 1 -u nagios >> /var/log/test.log Cronjob... (7 Replies)
Discussion started by: heady89
7 Replies

7. Shell Programming and Scripting

sed command not working inside ksh script but works fine outside

Hi, I am a bit confused ,why would a sed command work fine outside of ksh script but not inside. e.g I want to replace all the characters which end with a value and have space at end of it. so my command for it is : sed -i "s/$SEPARATOR /$SEPARATOR/g" file_name This is working fine in... (8 Replies)
Discussion started by: vital_parsley
8 Replies

8. Shell Programming and Scripting

awk working inside specific pattern ranges

Hi, I have a text file, which I am trying to parse. File contents: BEG Id Job1 Id Stage1 1 EN Id Job2 Id Stage2 BEG Id2 Job3 Id Stage4 2 EN I have to process the data in this between every BEG and EN. so I am trying to restrict the range and inside every... (1 Reply)
Discussion started by: Kulasekar
1 Replies

9. Shell Programming and Scripting

Expect not working inside my Bash script

I am trying to execute expect command inside by small bash script to login into servers using key authentication method. My script is as follows: #!/bin/bash HOST=$1 /usr/bin/expect -c " spawn ssh -i /root/.ssh/id_rsa root@$HOST expect -exact "Enter... (3 Replies)
Discussion started by: John Wilson
3 Replies

10. Shell Programming and Scripting

Nslookup on a variable inside script not working

I am new at scripting. I have a file that each line is the shortname for a server. ie - Server1 Server2 Server3 I want to read in that file, do a nslookup and print the FQDN to a file. I added an echo statement to make sure my variable was being read and changing. But the nslookup... (5 Replies)
Discussion started by: kellyhkc
5 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). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 02:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy