Adding a comment in a file next to data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding a comment in a file next to data
# 8  
Old 11-07-2016
Well - sometimes my mind reading works, and sometimes - the majority of times - it doesn't.

BTW, what I proposed can be simplified (as no FS nor OFS need to be defined) to:
Code:
awk  '/^<.*>$/ {PRFX = $0 ","; print; next} {sub (/^/, PRFX)}1'  file

# 9  
Old 11-07-2016
Hi

Thanks for help, it work as expected

---------- Post updated at 09:40 AM ---------- Previous update was at 08:19 AM ----------

Hi

When working with original file it just print ;

it is not printing content of the file. i just gave the few lines from the file. any reason?

Last edited by rbatte1; 11-07-2016 at 11:44 AM.. Reason: Added ICODE tags for the output ";"
# 10  
Old 11-07-2016
More details, please!
# 11  
Old 11-07-2016
Hi

I ran the below command
Code:
awk '/^</{a=$0";";print $0; next} {print a $0}' ED_D_SSL______004_006_001_000_EN.oti>ED_D_VLU.txt

the output it shows as
Code:
vi ED_D_VLU.txt
"ED_D_VLU.txt" 10990 lines, 10993 characters
\377\376<


Last edited by vbe; 11-07-2016 at 01:06 PM.. Reason: more code tags
# 12  
Old 11-07-2016
So you say it's an empty file? What's the file'e encoding? What you post seems like the introductory bytes of a UTF-16 file to me.
# 13  
Old 11-08-2016
Hi

Working fine your solution, there was a probelm in the file it had hexadecimal character so was not working
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding data from a file based on some condition

I collect data in a file in below format(Month Day Year Size) in RedHat Linux. Now i want to calculate the data size date wise. As i code shell script after long time, i forgot the features and syntax. Can anyone help me regard this please. Feb 8 2014 15 Feb 10 2014 32 Feb 10 2014 32 Feb 12... (2 Replies)
Discussion started by: makauser
2 Replies

2. Red Hat

Adding a data file

I need to add a data file, but my user account doesn't have privileges. I have connected to the oracle as sqlplus / as sysdba and it is telling me I'm connect to an idle instance. How can I connect to my database and create a data file if I don't know the passwords of any of the account that have... (1 Reply)
Discussion started by: FaSho76
1 Replies

3. Shell Programming and Scripting

Help in adding a data after a particular line of data in a file.

Hi.. I'm into a bump after trying to solve this prob.. i've a file with contents like below. <blankline> 'pgmId' : 'UNIX', 'pgmData' : 'textfile', 'author' : 'admin', ....... Now i'm trying to insert a new data after pgmId. so the final output will be... (7 Replies)
Discussion started by: arjun_arippa
7 Replies

4. Shell Programming and Scripting

adding data in input file if 2nd script output SUCCESS

Hi All, how can i edit my original data and add more data if my 2nd script outputs SUCESS? ex. input file: 1.txt nik,is,the 1script.sh if 2ndscript.sh output SUCCESS then i'm going to edit my input file and add data best,pogi.. sample outputdata. nik,is,the,best,pogi 2ndscript.sh... (3 Replies)
Discussion started by: nikki1200
3 Replies

5. Shell Programming and Scripting

Adding the data before file extension

HI , I have a file with multiple lines like below, I need to check on column starting with #prototype if it has the .Number.txt extension do nothing else add 1.txt extension. Source data Jdbc_app_data :- sample data #prototype= sample data from test.1.txt application_id=122135... (4 Replies)
Discussion started by: gaur.deepti
4 Replies

6. Shell Programming and Scripting

Adding data in a file on same line

Hi, I have one file a.txt ,the contents of the file is A B C D E F and I have another file b.txt, the contents of the file is 1 2 3 4 5 6 now when I am using this command cat a.txt b.txt > c.txtI am getting the output as A B C D E F 1 2 3 4 5 6 but i need the output... (2 Replies)
Discussion started by: prarat
2 Replies

7. Shell Programming and Scripting

sed adding/removing comment in crontab

I have a requirement where I want to add a comment '#' in my crontab, run a process, than remove the '#' I added. Example cron #5,10 * * * * ls -lt /tmp 10,5 * * * * ls -lt /var I would like to be able use sed or awk to add a '#' at the begining of each line. After the command... (4 Replies)
Discussion started by: BeefStu
4 Replies

8. Shell Programming and Scripting

Pulling data from a standard comment block - perl

OK so I've inherited a set of scripts that do some work on a database. They do all have a standard comment block at the beginning that has good information on the script. I would like to generate a quick web page report that lists the script name and the description lines (for now it may be... (1 Reply)
Discussion started by: khuilman
1 Replies

9. Shell Programming and Scripting

adding the data at a specified location in a file....

Hi all, I m new to shell programming..Can anyone please guide me how to insert data at a specified location in the file.. I have a configuration file..I want to add data to it through script..I am able to do it...I get that data written at end of my configuration file..I want data to be placed at... (3 Replies)
Discussion started by: divya_flora
3 Replies

10. Shell Programming and Scripting

Need Help for Adding Three new columns in existing file from fatching data from file

not required this time (36 Replies)
Discussion started by: Sandeep_Malik
36 Replies
Login or Register to Ask a Question