adding data in input file if 2nd script output SUCCESS


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting adding data in input file if 2nd script output SUCCESS
# 1  
Old 10-27-2011
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
output is SUCCESS

how am i sopposed to do that? i dont have any idea.T_T

Please advise,
THanks,
# 2  
Old 10-27-2011
Code:
if [  `2ndscript.sh|grep SUCCESS |wc -l` -gt 0 ] ; then
  sed -i 's/$/&,best,pogic/' input
fi

This User Gave Thanks to rdcwayx For This Post:
# 3  
Old 10-27-2011
thank you sir rdcwayx. i'm going to try it. thx..

---------- Post updated at 06:27 PM ---------- Previous update was at 06:15 PM ----------

tank you very much! ^_^

---------- Post updated at 06:31 PM ---------- Previous update was at 06:27 PM ----------

Hi Sir,

may i know what is the meaning of your code?
Code:
sed -i 's/$/&,best,pogic/' input

Thanks,
# 4  
Old 10-27-2011
that's sed replace command, "&" used to add chars after each line.
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 get the shell script to read the .txt file as an input/data?

i have written my shell script in notepad however i am struggling to pass the data file to be read to the script the data file is of .txt format. My target is to run the shell script from the terminal and pass 3 arguments e.g. polg@DESKTOP-BVPDC5C:~/CS1420/coursework$ bash valsplit.sh input.txt... (11 Replies)
Discussion started by: Gurdza32
11 Replies

2. Shell Programming and Scripting

awk to reformat output if input file is empty, but not if file has data in it

The below awk improved bu @MadeInGermany, works great as long as the input file has data in it in the below format: input chrX 25031028 25031925 chrX:25031028-25031925 ARX 631 18 chrX 25031028 25031925 chrX:25031028-25031925 ARX 632 14... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. UNIX for Dummies Questions & Answers

Inserting shell script input data automatically from a text file

Dear experts, I am new to linux programming. I have a shell script which i should run it on all my samples. I only define input and out put for this script. The inputs are 3 numbers(coordination numbers) which are available in a series of text file. Since i have a lots of samples, it takes a... (5 Replies)
Discussion started by: mohamadreza
5 Replies

4. Shell Programming and Scripting

Shell Script - File Input/Output in C

This is part of my code: for in_file in $1/*.in # list of all .in files in working directory. do $c_file < $in_file > "$tempFile.out" if diff "$tempFile.out" $out_file >/dev/null 2>&1 ; then ... (6 Replies)
Discussion started by: spider-man
6 Replies

5. Shell Programming and Scripting

split input data file and put into same output file

Hi All, I have two input file and need to generate a CSV file. The existing report just "GREP" the records with the Header and Tailer records with the count of records. Now i need to split the data into 25 records each in the same CSV file. id_file (Input file ) 227050994 232510151... (4 Replies)
Discussion started by: rasmith
4 Replies

6. Shell Programming and Scripting

How to add data from 2 input files and save it in 1 output file

Hi, i have 2 input files which are file1.txt and file2.txt. I need to extract data from file1.txt and file2.txt and save it in file3.txt like example below:- File1.txt ID scrap1 Name scrap1 start 1 end 10 ID scrap2 Name scrap2 start 11 end ... (4 Replies)
Discussion started by: redse171
4 Replies

7. Shell Programming and Scripting

AWK Script to convert input file(s) to output file

Hi All, I am hoping someone can help me with some scripting I need to complete using AWK. I'm trying to process multiple fixed files to generate one concatenated fixed file in a standard format. The Input file is:- aaaa bbbbb ccccc 1 xxxx aaa bbb aaaa bbbbb ccccc 2 abcd aaa CCC... (9 Replies)
Discussion started by: jason_v_brown
9 Replies

8. Shell Programming and Scripting

Need script to take input from file, match on it in file 2 and input data

All, I am trying to figure out a script to run in windows that will allow me to match on First column in file1 to 8th Column in File2 then Insert file1 column2 to file2 column4 then create a new file. File1: 12345 Sam 12346 Bob 12347 Bill File2:... (1 Reply)
Discussion started by: darkoth
1 Replies

9. Shell Programming and Scripting

Pass input and output file as parameter to awk script

Hi, i am new to awk. I am using csv2pipe script(shown below) BEGIN { FS=SUBSEP; OFS="|" } { result = setcsv($0, ",") print } # setcsv(str, sep) - parse CSV (MS specification) input # str, the string to be parsed. (Most likely $0.) # sep, the separator between the values. # #... (6 Replies)
Discussion started by: bhaskarjha178
6 Replies

10. Shell Programming and Scripting

Replacing data of output file with input

Hi, I have a ksh which peocess and get me data from 3 days... ie if i process it on jan 28.. it gets data for 25, 26 and 27.... the process run every day and get previous 3 days data...all this data is appened to a file lets call time.out Now time.out cannot have deplicate data so what i want... (10 Replies)
Discussion started by: bhagya2340
10 Replies
Login or Register to Ask a Question