Sponsored Content
Top Forums Shell Programming and Scripting Date conversion in row while preserving rest of fields Post 302505704 by pchang on Thursday 17th of March 2011 03:33:27 PM
Old 03-17-2011
Vgersh99.

Your code solution was awesome and works great.

Would you mind explaining the awk code portion?

I would like to understand the code better.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

column to row conversion with additional pattern

Hi there, I've an input file1 as follows: 1001 1002 1003 1004 1005 I would like to have an output file2 as follows: Numbers are 1001/ 1002/ 1003/ 1004/ 1005/ Any help is appreciated. (2 Replies)
Discussion started by: kbirde
2 Replies

2. Shell Programming and Scripting

To count distinct fields in a row

I have . dat file which contains data in a specific format: 0 3 892 921 342 1 3 921 342 543 2 4 817 562 718 765 3 3 819 562 717 761 i need to compare each field in a row with another field of the same column but different row and cont the... (8 Replies)
Discussion started by: Abhik
8 Replies

3. Shell Programming and Scripting

Identifying specific fields in a Row

Hi, I am new to UNIX. Can some one help me to solve the below. I have a requirement to to identify the specific fields in row and also some part of the field. In my file I have a record as sundra;10.44.48.65;10thstreet TCP packet out of state: First packet isn't SYN;telno:... (3 Replies)
Discussion started by: suneel.mekala
3 Replies

4. Shell Programming and Scripting

Julian date to Calendar date conversion

Hi all, I require to convert julian date to normal calander date in unix for eg julian date=122 now i want corresponding calander date ---------------------------------------- gr8 if give very small command/script and please explain the steps as well(imp) Thanks ... (3 Replies)
Discussion started by: RahulJoshi
3 Replies

5. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

6. Shell Programming and Scripting

complicated row to rows conversion

I have a file containing rows with the following format. Field1|Field2|Field3|data1:data data2:data data3:"dataA:data dataB:data" data4:data:data (and so on) I need to format the above row into multiple rows that look like this: Field1|Field2|Field3|data1|data ... (2 Replies)
Discussion started by: newreverie
2 Replies

7. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

8. Shell Programming and Scripting

Row to Column conversion?

I have a text file with the geneIds separated by space in each line. The number Ids in lines are different. The file is like: abc qwe tyu ghj jkl dfg sdf cvb sdk fgh tyu uio iop tyu rty eru wer rty iop asd sdf dfg fgh zxc I want to format the file like: abc qwe tyu ghj jkl ... (7 Replies)
Discussion started by: sammy777
7 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Uneven column to row conversion

Hi Unix Forum, I have a relatively easy question i suppose for which, however, until now i could not find a solution. I am working with a program that will give me an output file similar to the following: A 1 2 3 4 B 1 2 3 4 C 1 (9 Replies)
Discussion started by: Leander
9 Replies

10. Shell Programming and Scripting

Analyzing last 2 fields of 1 row and 3rd field of next row

I have the following script that will average the last two fields of each row, but im not sure how to include the 3rd field of the following row. An example of the analysis that I need to perform from the input - (66.61+58.01+54.16)/3 awk '{sum=cnt=0; for (i=13;i<=NF;i++) { sum+=$i; cnt++... (1 Reply)
Discussion started by: ncwxpanther
1 Replies
fwtmp(8)						      System Manager's Manual							  fwtmp(8)

NAME
fwtmp, acctwtmp, wtmpfix - Modify connect time accounting records to change formats and to make corrections in the records SYNOPSIS
fwtmp [-ic] acctwtmp 'Reason' wtmpfix [File . . .] FLAGS
The fwtmp command accepts ASCII records in the type utmp structure format as input. The fwtmp command converts output to type utmp struc- ture formatted binary records. The fwtmp command converts ASCII type utmp structure formatted input records to binary output records. DESCRIPTION
fwtmp [-ic] The fwtmp command reads records from standard input and writes records to standard output. Normally, information in record fields of the /var/adm/wtmp file is entered as binary data by the init and login programs during the life of the /var/adm/wtmp file. These /var/adm/wtmp file records have nine fields formatted according to members of a type utmp structure defined in the utmp.h include file. The fwtmp command is also capable of writing properly formatted ASCII records from standard input into a file when you use the -i flag. Whenever you enter properly formatted ASCII records for conversion to binary records using the -i flag from the standard input device, you must enter data for each field of the 9-field record in the same order as that of type utmp structure members using a space as a field sep- arator. The following table lists record fields in the order they should be entered, the type utmp structure member name, and the purpose and entry character length. The user login name, which must have exactly sizeof(ut_user) characters. The inittab ID, which must have exactly sizeof(ut_id) characters. The device name, which must have exactly sizeof(ut_line) characters. The process ID, which must have 5 decimal places. The type of entry, which must have 2 decimal places. The type of entry may have any one of several symbolic constant val- ues. The symbolic constants are defined in the utmp.h header file. The process termination status, which must have 4 decimal places. The process exit status, which must have 4 decimal places. The starting time, which must have 10 decimal places. The hostname, which must have exactly sizeof(ut_host) characters. All record field entries you make from standard input must be separated by a space. Also you must fill all string fields with blank charac- ters up to the maximum string size. All decimal values must have the specified number of decimal places with preceding 0s (zeros) to fill empty digit positions. The actual size of character arrays can be found in the utmp.h include file. acctwtmp 'Reason' The acctwtmp command is called by the runacct shell procedure to write a utmp formatted record to standard output with the current date and time together with a 'Reason' string (sizeof(ut_line) characters or less) that you must also enter. wtmpfix [File ...] The wtmpfix command is called by the runacct shell procedure to examine standard input or File records in the wtmp format for corrupted date and timestamp entries. Whenever a corrupted entry is detected, the wtmpfix command corrects date and timestamp inconsistencies and writes corrected records to standard output. Whenever the acctcon1 command runs, and a date and timestamp in a /var/adm/wtmp file is incor- rect, an error is generated when the first corrupted entry is encountered. The acctcon1 process is aborted whenever such an error is detected. The wtmpfix command also checks the validity of the name field to ensure that the name consists only of alphanumeric characters, a $ (dol- lar sign), or spaces. Whenever an invalid name is detected, the wtmpfix command changes the login name to INVALID and writes a diagnostic message to standard error. In this way, the wtmpfix command reduces the likelihood that the acctcon2 command may fail. Each time a date is entered (on system startup or with the date command) a pair of date-change records is written to the /var/adm/wtmp file. The first date-change record is the old date, which is entered with the string old time (the OTIME_MSG string) in the ut_line field and the flag OLD_TIME in the ut_type field. The second record is the new date, which is entered with the string new time (the NTIME_MSG string) in the ut_line field and the flag NEW_TIME in the ut_type field. The wtmpfix command uses these records to synchronize all date and time stamps in the /var/adm/wtmp file. The date-change record pair is then removed. RESTRICTIONS
You should not use the fwtmp command to correct connect-time accounting records because the utmp structure format members are not in the correct order for this operation. EXAMPLES
To convert binary /var/adm/wtmp records in type utmp structure format to an ASCII file called dummy.file, enter a command similar to the following: /usr/sbin/acct/fwtmp < /var/adm/wtmp > dummy.file The content of binary file /var/adm/wtmpfile as input is redirected to dummy.file as ASCII output. To convert records in an ASCII type utmp structure formatted file to a binary output file called /var/adm/wtmp, enter an fwtmp command with the -ic flag similar to the following: /usr/sbin/acct/fwtmp -ic < dummy.file > /var/adm/wtmp The content of ASCII file dummy.file as input is redirected to binary file /var/adm/wtmp as output. FILES
Specifies the command path. Specifies the command path. Specifies the command path. Header file defining structures used to organize login information. Database file for currently logged in users. Login/logout database file. RELATED INFORMATION
Commands: acct(8), acctcon(8), acctmerg(8), date(1), runacct(8) Functions: acct(2) delim off fwtmp(8)
All times are GMT -4. The time now is 06:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy