Append your messaage in UNIX command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Append your messaage in UNIX command
# 1  
Old 03-09-2014
Append your messaage in UNIX command

Hi All,

I am executing this command to capture all the outputs from Error_*.txt files to all.txt file as a single output.

Code:
head -n -5 Error_*.txt > all.txt

It gives me the output in all.txt as:

Code:
==> ErrorLog_batchSearch.txt <==
2014-03-09 17:07:28,193 ERROR [nucleusNamespace.] Cannot parse property value "null" of 

==> ErrorLog_content.txt <==

==> ErrorLog_lockServer.txt <==

==> ErrorLog_mobile.txt <==

Now I want to append some Message after every
Code:
==> ErrorLog_content.txt <==

in the same line as :
Code:
==> ErrorLog_content.txt <==  Here are the errors:


Can somebody please help me on this.

Thanks
# 2  
Old 03-09-2014
Try
Code:
sed 's/==> ErrorLog_content.txt <==/& Here are the errors:/' file

# 3  
Old 03-09-2014
The file output is as:

Code:
==> ErrorLog_batchSearch.txt <==
2014-03-09 17:07:28,193 ERROR [nucleusNamespace.] Cannot parse property value "null" of "/atg/commerce/order/abandoned/AbandonedOrderService.schedule" as a atg.service.scheduler.Schedule java.lang.IllegalArgumentException: atg.nucleus.PropertyValueParseException: Invalid Schedule format

==> ErrorLog_content.txt <==

==> ErrorLog_dataLoader.txt <==

==> ErrorLog_fulfillment.txt <==

==> ErrorLog_liveSearch.txt <==

==> ErrorLog_lockServer.txt <==

How to append lines in after every :
Code:
==> ErrorLog_*.txt <== : My line here

# 4  
Old 03-09-2014
You need to give us more clarity. What message do you want to append after every ErrorLog_*.txt? Is the message same or is it different?
# 5  
Old 03-09-2014
Message would be a static line like : The errors are:
# 6  
Old 03-09-2014
Code:
awk '/ErrorLog_*.txt/{$0=$0 " The errors are:"} 1' infile

Code:
sed 's/.*ErrorLog_.*txt.*/& The errors are:/'

# 7  
Old 03-09-2014
Thanks Ahamed.

I am also facing another problem. I have a list of files and they contain errors. I am concatenating all of them by this command:


Code:
cd /temporary/
    head -n -500 ErrorLog_*.txt > all.txt



and then seeing the all.txt output as:

Code:
==> ErrorLog_batchSearch.txt <==

==> ErrorLog_content.txt <==

==> ErrorLog_fulfillment.txt <==

==> ErrorLog_service.txt <==

Why it is skipping the lines. The ErrorLog_* are not empty!

---------- Post updated at 01:29 AM ---------- Previous update was at 01:25 AM ----------

I tried with this:

Code:
  head -n -1 ErrorLog_*.txt > all.txt

But

Code:
==> ErrorLog_content.txt <==

==> ErrorLog_fulfillment.txt <==

they are printed as empty though they have a single line inside them!!

---------- Post updated at 01:38 AM ---------- Previous update was at 01:29 AM ----------

Solved by this

Code:
head -n999999

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to append a value to the output after using sed command?

Hi All, I have a file where I am converting newlines to comma separated values but I would like to append zero if the output is empty Here is the command I am using sed -n -e 'H;${x;s/\n/,/g;s/^,//;p;}' test1.txt test1.txt will have comma seperated values but sometimes this file can be... (6 Replies)
Discussion started by: rajeevm
6 Replies

2. Shell Programming and Scripting

awk - append date to output of a command

Hi all; I am running a script:/var/tmp/gcsw -ne | grep "State:2" | wc that gives me output like:80 480 6529 but i need this output as:2013-01-18 13:00 -> 80 480 6529 (1 Reply)
Discussion started by: gc_sw
1 Replies

3. Shell Programming and Scripting

How to use variables in 'sed' append command?

HELLO!! I'm trying to pass a variable with in the 'sed' command (which would add some piece of code to file at a particular line). We can use sed '{line-number}a\ alfjaljf\ aslfjsfsjafl\ adlfjaf\' file.txt If file.txt is Now, I would like to add the parameter 'lmn' after... (1 Reply)
Discussion started by: mjavalkar
1 Replies

4. Shell Programming and Scripting

How to append something to a word using sed command

Hi, How to append something to already existing word. Suppose, I have the following line as a part of a file. VVV= jdbc:... (6 Replies)
Discussion started by: Dpu
6 Replies

5. Shell Programming and Scripting

Need to append the last line of a file on UNIX Box

Dear Friends, I would like to apend the last line of one file on my UNIX box. Please let me know if you have any suggetsion for this. E.g: I have a file ABC as below Required Help Rajesh Amathi | | Thanks in advance. Result: I would like the get the output i.e. file ABC should... (9 Replies)
Discussion started by: rajeshamathi
9 Replies

6. Shell Programming and Scripting

Truncate and Append in unix shell scripting

Hi All, I have a long log file (abc.log) which contains large volume of data that need to be inserted into the database as clob. I am having problem in inserting the long log file into the clob field if the cahracters in the file exceeds. So iwould like to truncate the file upto 32767... (3 Replies)
Discussion started by: rajeshorpu
3 Replies

7. UNIX for Advanced & Expert Users

Append the file in UNIX

Hello All, Could you please provide the solution to my following query I have some files in my directory. I need to amend the total number of lines to be added in the starting line of each file. For example, please refer the content of the file "file.dat" below. \h:\w #> cat file.dat... (1 Reply)
Discussion started by: sdosanjh
1 Replies

8. AIX

append file with tar command

hello, can i append files into tape without clear this tape thanks for help (3 Replies)
Discussion started by: mbakry23
3 Replies

9. Shell Programming and Scripting

Need help with command to append strings

Greetings all, I'm in need of some help in coming up with this command which requires me to append 5 strings together: 1. echo "Status from system:" 2. `cat logs.txt` (i need the output of this command) 3. echo "Error output: " 4. `cat errors.txt`(i need the output of this command) 5.... (3 Replies)
Discussion started by: rockysfr
3 Replies

10. Shell Programming and Scripting

Is there any way to append pdf files in UNIX?

Is there any way to append pdf files in UNIX? I have a apllication which creates pdf files. Now i want to append them so that it gives me one pdf file. Is this possible? (2 Replies)
Discussion started by: cp7800
2 Replies
Login or Register to Ask a Question