Sponsored Content
Top Forums Shell Programming and Scripting how to add extra a field in a flat txt file ? Post 302512187 by britney on Friday 8th of April 2011 02:59:04 PM
Old 04-08-2011
how to add extra a field in a flat txt file ?

Hi all,

I did not use UNIX for a long time, now i need to make a flat file with extra field, can you help me with the code ?
1. I create a last line of each log from each system and make it in a flat text file (seperate by a pipe |)
mv current.log old
tail -1 sanfrancisco.log > current.log
tail -1 oakland.log >> current.log

Current.log
Code:
2011/04/07 14:49:46 |   61:linux   pid=027546 opened Boards 0, 1, 2, 3 for /home/goniners/abcd/
2011/04/08 08:13:39 |  255:linux   pid=016870 opened Boards 0, 1, 2, 3, 4, 6 for /home/gosteelers/asdas/

2. How do we create new.log which have a hostname in a 2nd fields ?
Code:
2011/04/07 14:49:46 |sanfrancisco|   61:linux   pid=027546 opened Boards 0, 1, 2, 3 for /home/goniners/abcd/
2011/04/08 08:13:39 |oakland|  255:linux   pid=016870 opened Boards 0, 1, 2, 3, 4, 6 for /home/gosteelers/asdas/

Thanks,
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reindex or re-increment last field of txt file.

I am using a database text file with a field that increments +1 with each new entry, occasionally if a entry is deleted the unique sequence is disrupted. I am looking for a small script/function in sh and/or perl that would re index this. Example of db file: Name | Address | misc |number... (2 Replies)
Discussion started by: silenthands
2 Replies

2. Shell Programming and Scripting

`find`, pulling 1st field from ASCII flat file as search/-name?

Hey Everyone! I have searched around for this on Unix.com and Google, and I'm either not phrasing my search properly or this is not as simple as I thought... I have a script that runs on a nightly basis that pulls one field worth of data from an internal MySQL database and populates to an... (2 Replies)
Discussion started by: Gecko12332
2 Replies

3. Shell Programming and Scripting

gawk help for inserting a field of a .txt file in the same file

i had the following type of data file vchrdump: Vouchers For Date :05/01/2009 * ... (4 Replies)
Discussion started by: KANNI786
4 Replies

4. UNIX for Advanced & Expert Users

Find and replace txt between two strings in flat file

Hi There... I need to serach and replace strngs in a text file. My file has; books.amazon='Let me read' news.bestseller='xyz' expected output is books.amazon=NONFOUND news.bestseller=NONFOUND Can I first find the text between string1= books.amazon=' and string2= ' (locate the text... (1 Reply)
Discussion started by: Hiano
1 Replies

5. Shell Programming and Scripting

Find the position of a field/column in a flat file

Hi, Let say I have a file which has around 400 fields. SampleFile ========= PATIENTID|FACILITY|................|TIME_LAST_VISITED_BY_MD|.....|STATUS| How is it possible to find out which field is TIME_LAST_VISITED_BY_MD?fro example by seeing the above structure we can saw FACILITY... (5 Replies)
Discussion started by: machomaddy
5 Replies

6. UNIX for Dummies Questions & Answers

Inserting a sequential number into a field on a flat file

I have a csv flatfile with a few million rows. I need to replace a field (field number is 85) in the file with a sequential number. As an example, let's assume there are only 4 fields in the file: A,A,,32 A,A,,27 A,B,,43 C,C,,354 If I wanted to amend the 3rd field in this way my... (2 Replies)
Discussion started by: BristolSmithy
2 Replies

7. UNIX for Dummies Questions & Answers

To Add extra commas to a CSV file.

Hi All, I got this requirement to process a complex CSV file. Eg File. Line 1: Name:,XYz Line 2: Age:,15 Line 3: Grade:,7 Line 4: Line 5: English, Maths, Science,Spanish Line 6:10,11,13,14 As you can see the maximum column is 4 . The file i need to make is Line 1: Name:,XYz,,... (12 Replies)
Discussion started by: chillblue
12 Replies

8. Shell Programming and Scripting

awk to place value at 24 field in a flat file issue

I am trying to add 0393 value at 24th feild using the below command, but its adding at all the lines including header and trailer Input file: ZHV|2657|D0217001|T|TXU|Z|PAN|20131112000552||||OPER| 754|52479| 492|489|SP40|1014570286334|20131111|20131201|14355334|CHAMELON... (1 Reply)
Discussion started by: Aditya_001
1 Replies

9. Shell Programming and Scripting

Adding Extra Column in txt file base on Condition

HI Guys, I have below input. Output Base on Below Condition. 1> if forth column is empty and next coming line have same name with \es then add that column name on all rows 2>rest of all are es:vsDataEUtranCellFDD Input:- CCL01736 CCL01736_7A_1 es:vsDataEUtranCellFDD ... (3 Replies)
Discussion started by: pareshkp
3 Replies

10. Windows & DOS: Issues & Discussions

2 Questions: replace text in txt file, add text to end of txt file

so... Lets assume I have a text file. The text file contains multiple "#" symbols. I want to replace all thos "#"s with a STRING using DOS/Batch I want to add a certain TEXT to the end of each line. How can I do this WITHOUT aid of sed, grep or anything linux related ? (1 Reply)
Discussion started by: pasc
1 Replies
ALBATROSS(8)						      System Manager's Manual						      ALBATROSS(8)

NAME
al-session-daemon -- session daemon for Albatross web applications SYNOPSIS
al-session-daemon [-D, --debug] [-h, --help] [-k, --pidfile pid-file] [-p, --port port] [-l, --log log-file] [command] DESCRIPTION
This manual page documents briefly the al-session-daemon command. This manual page was written for the Debian distribution because the original program does not have a manual page. al-session-daemon is a daemon that implements a session server for Albatross web applications. It can store simple pieces of information for later retrieval. With the help of this daemon, you can distribute your Albatross web application across several web servers and store the sessions in one place. OPTIONS
A summary of options is included below. -D --debug Write debugging to log. -h --help Display program help. -k --pidfile Record server pid in pid-file, default is /var/run/al-session-daemon.pid. -p --port Listen on port, default is 34343. -l --log Write log to log-file, default is /var/log/al-session-daemon.log. AUTHOR
This manual page was written by Fabian Fagerholm fabbe@debian.org for the Debian system (but may be used by others). Permission is granted to redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ALBATROSS(8)
All times are GMT -4. The time now is 12:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy