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
mkmsgs(1)							   User Commands							 mkmsgs(1)

NAME
mkmsgs - create message files for use by gettxt SYNOPSIS
mkmsgs [-o] [-i locale] inputstrings msgfile DESCRIPTION
The mkmsgs utility is used to create a file of text strings that can be accessed using the text retrieval tools (see gettxt(1), srchtxt(1), exstr(1), and gettxt(3C)). It will take as input a file of text strings for a particular geographic locale (see setlocale(3C)) and create a file of text strings in a format that can be retrieved by both gettxt(1) and gettxt(3C). By using the -i option, you can install the cre- ated file under the /usr/lib/locale/locale/LC_MESSAGES directory (locale corresponds to the language in which the text strings are writ- ten). inputstrings is the name of the file that contains the original text strings. msgfile is the name of the output file where mkmsgs writes the strings in a format that is readable by gettxt(1) and gettxt(3C). The name of msgfile can be up to 14 characters in length, but may not contain either (null) or the ASCII code for / (slash) or : (colon). The input file contains a set of text strings for the particular geographic locale. Text strings are separated by a newline character. Non- graphic characters must be represented as alphabetic escape sequences. Messages are transformed and copied sequentially from inputstrings to msgfile. To generate an empty message in msgfile, leave an empty line at the correct place in inputstrings. Strings can be changed simply by editing the file inputstrings. New strings must be added only at the end of the file; then a new msgfile file must be created and installed in the correct place. If this procedure is not followed, the retrieval function will retrieve the wrong string and software compatibility will be broken. OPTIONS
The following options are supported: -o Overwrite msgfile, if it exists. -i locale Install msgfile in the /usr/lib/locale/locale/LC_MESSAGES directory. Only someone who is super user or a member of group bin can create or overwrite files in this directory. Directories under /usr/lib/locale will be created if they do not exist. EXAMPLES
Example 1: Using the mkmsgs command. The following example shows an input message source file C.str: File %s: cannot be opened %s: Bad directory . . . write error . . Example 2: Using Input Strings From C.str to Create Text Strings in a File The following command uses the input strings from C.str to create text strings in the appropriate format in the file UX in the current directory: example% mkmsgs C.str UX Example 3: Using Input Strings From FR.str to Create Text Strings in a File The following command uses the input strings from FR.str to create text strings in the appropriate format in the file UX in the directory /usr/lib/locale/fr/LC_MESSAGES: example% mkmsgs -i fr FR.str UX These text strings would be accessed if you had set the environment variable LC_MESSAGES=fr and then invoked one of the text retrieval tools listed at the beginning of the DESCRIPTION section. FILES
/usr/lib/locale/locale/LC_MESSAGES/* message files created by mkmsgs ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWloc | +-----------------------------+-----------------------------+ SEE ALSO
exstr(1), gettxt(1), srchtxt(1), gettxt(3C), setlocale(3C), attributes(5) SunOS 5.10 26 Jul 1994 mkmsgs(1)
All times are GMT -4. The time now is 09:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy