Small query on modifying the text of file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Small query on modifying the text of file
# 1  
Old 10-19-2012
Small query on modifying the text of file

Hi,
I have file with the following text,
Code:
 
/analysis2012/533/mc_S10_533/DYJets50/vgtree_1_1_33l.root
/analysis2012/533/mc_S10_533/DYJets50/vgtree_2_5_33l.root
/analysis2012/533/mc_S10_533/DYJets50/vgtree_6_7_33l.root


and many such files. For some operation on these files, I would like it to be like
Code:
/analysis2012/533/mc_S10_533/DYJets50/vgtree_1_1_33l.root /analysis2012/533/mc_S10_533/DYJets50/vgtree_2_5_33l.root  /analysis2012/533/mc_S10_533/DYJets50/vgtree_6_7_33l.root

thanks in advance,
emily,
# 2  
Old 10-19-2012
Is this what you want?

Code:
cat inputfile | while read line 
do
   echo "${line} \c" >> outputfile
done

# 3  
Old 10-19-2012
Hi, I did the following
Code:
$ cat test.out | while read line; do  print "${line} \c" >> outputfile; done
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found

Smilie
emily,
# 4  
Old 10-19-2012
Quote:
Originally Posted by emily
Hi, I did the following
Code:
$ cat test.out | while read line; do  print "${line} \c" >> outputfile; done
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found
-bash: print: command not found

Smilie
emily,
Please replace it with echo
# 5  
Old 10-19-2012
I tried that and the response is :
Code:
/analysis2012/533/mc_S10_533/DYJets50/vgtree_602_0_UNQ.root \c
/analysis2012/533/mc_S10_533/DYJets50/vgtree_606_0_UNQ.root \c

thats not what I want...:-o
# 6  
Old 10-19-2012
Code:
 cat file
/analysis2012/533/mc_S10_533/DYJets50/vgtree_1_1_33l.root
/analysis2012/533/mc_S10_533/DYJets50/vgtree_2_5_33l.root
/analysis2012/533/mc_S10_533/DYJets50/vgtree_6_7_33l.root

sed -e :start -e N -e 's/\n/ /' -e tstart file

/analysis2012/533/mc_S10_533/DYJets50/vgtree_1_1_33l.root /analysis2012/533/mc_S10_533/DYJets50/vgtree_2_5_33l.root /analysis2012/533/mc_S10_533/DYJets50/vgtree_6_7_33l.root

# 7  
Old 10-19-2012
Thank U..SmilieSmilieSmilie it workrd
Quote:
Originally Posted by in2nix4life
Code:
 
 cat file
/analysis2012/533/mc_S10_533/DYJets50/vgtree_1_1_33l.root
/analysis2012/533/mc_S10_533/DYJets50/vgtree_2_5_33l.root
/analysis2012/533/mc_S10_533/DYJets50/vgtree_6_7_33l.root

sed -e :start -e N -e 's/\n/ /' -e tstart file

/analysis2012/533/mc_S10_533/DYJets50/vgtree_1_1_33l.root /analysis2012/533/mc_S10_533/DYJets50/vgtree_2_5_33l.root /analysis2012/533/mc_S10_533/DYJets50/vgtree_6_7_33l.root

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to write MySQL query in text file and run in Linux?

I would like to call a .sql file from a .sh file in linux. The .sql file will contain queries to MySQL database. I am able to call the .sql file by running .sh file in linux, but the sql query is not working. Below is my syntax. The select statement is throwing below error. ./sample.sql: line... (1 Reply)
Discussion started by: qytan
1 Replies

2. Shell Programming and Scripting

Modifying text file records, find data in one place in the record and print it elsewhere

Hello, I have some text data that is in the form of multi-line records. Each record ends with the string $$$$ and the next record starts on the next line. RDKit 2D 15 14 0 0 0 0 0 0 0 0999 V2000 5.4596 2.1267 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 ... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

3. Shell Programming and Scripting

To extract query from a text file.

Hi, I've a txt file with the following contents: variable = "select name, emp_id, org_name " variable = variable + " from table_name where " variable = variable + " condition_1 = ABC and " variable = variable + " condition_2 = DEF " varaible = variable + " order by other condition " ... (7 Replies)
Discussion started by: arjun_arippa
7 Replies

4. Shell Programming and Scripting

Removing duplicate sequences and modifying a text file

Hi. I've tried several different programs to try and solve this problem, but none of them seem to have done exactly what I want (and I need the file in a very specific format). I have a large file of DNA sequences in a multifasta file like this, with around 15 000 genes: ... (2 Replies)
Discussion started by: 4galaxy7
2 Replies

5. Shell Programming and Scripting

Text Formating or Modifying

Hi Experts, I have a text exactly like below in a file: id item_id item_date prin_mkt_val --------------------------- --------------------------- ------------------------------- ------------------------ ... (1 Reply)
Discussion started by: apatil65
1 Replies

6. Solaris

Mysql query reading a text file.

Hi, Is there any way that mysql query reads the content from a text file which has data in the below format: 1,2,3,4,5 and selects matched data from another table. ie I have a table named xyz which has same ids as in that file. I want this query to get count of the ids from xyz file by... (6 Replies)
Discussion started by: jyothi_wipro
6 Replies

7. Shell Programming and Scripting

Inserting text and modifying the file

I am in a dire need of doing this job , please help from shell script or perl script. It will be highly appreciated. Please have a look at the following INPUT file; The first 14 rows are not of interest but I want them to be included in the output file as they are. From the row 14... (3 Replies)
Discussion started by: digipak
3 Replies

8. Shell Programming and Scripting

shellscript.query Oracle table..populate in a text file

Hi Guys, I'm new to this forum as well as to UNIX shell scripting. I'm looking for a shellscript to query an Oracle database table and populate the result set of the query in a text file. Could you someone help me out with a sample code? Thanks, Bhagat (7 Replies)
Discussion started by: bhagat.singh-j
7 Replies

9. Shell Programming and Scripting

Help need in modifying the text of .txt file

Hi All, I've written a shell script in which i defined two varibles for example: str=1.0.0.15 timeStamp=2008.03.08 now using this varibles i need to modify a text file. The text content looks like this ************************ * packageNumber : 1.0.0.14 * * date :... (2 Replies)
Discussion started by: vinna
2 Replies

10. UNIX for Dummies Questions & Answers

small semaphore query

While using semget function we use the flag 0777 | IPC_CREAT or IPC_CREAT |0666 . What is the significance of these numbers and the order in which they are written ? (1 Reply)
Discussion started by: pramit bhuyan
1 Replies
Login or Register to Ask a Question