Find and Append

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find and Append
# 1  
Old 10-02-2013
Hammer & Screwdriver Find and Append

I'm not sure this is the *best* idea but it's what occurs to me:
I have a long bibliographical list where the entries are in a variety of forms. So, there's no consistent format.
I can pretty much find the year of publication buried in each line. Everything else is a bit of a mess. So, human intervention is going to be necessary but I'd like to help that as much as possible.
So my thought is to find things and add them to the end of the line in each case. The year for example.
Then, I figure one could add other strings to the end that look "likely" for the title, author(s), etc.

I'd be happy right now simply knowing how to append what's found to the end of the line - so it will stand out to a reader/editor. Surely some amount of debugging will be needed and this seems like it would help the most.
# 2  
Old 10-02-2013
It's best to post examples. In these cases I try to find some sort of consistency that will at least separate the original file into a series of similar cases.
# 3  
Old 10-02-2013
Here's the example that I have to work with....
# 4  
Old 10-02-2013
Sorry, this one has proper line breaks......
# 5  
Old 10-03-2013
Since year are always present in parentheses, you can do like this to get it out at end of line.
awk -F"[()]" '{print $0 "," $2}' file

Other stuff are more difficult since it varies.
# 6  
Old 10-03-2013
You may want to test this as a starting point, but, as there's no general structure to the file, further refinement becomes difficult:
sed 's/\(.*\)(/Author:\t\1\nYear:\t/;s/\(.*\))/\1\n\Title:\t/;s/$/\n/'  /tmp/Ackoff\ RL.txt
Author:    Ackoff RL 
Year:    1974
Title:    . Redesigning the Future. John Wiley & Sons: New York.

Author:    Ackoff RL and Gharajedaghi J 
Year:    1996
Title:    . Reflections on systems and their models. Syst Res Behav Sci 13: 13-22. 

Author:    Ackoff R.L. and Sasieni M.W. 
Year:    1968
Title:    . Fundamentals of Operations Research. Wiley: New York.

Author:    Ackoff R 
Year:    1999
Title:     Re-creating the corporation: a design of organizations for the 21st century. Oxford University Press, New York

Author:    Ackoff Russell et al. 
Year:    1976
Title:     Designing a national scientific and technological communications systems: The SCATT Report. 

Author:    Russel L Ackoff 
Year:    1981
Title:    . Creating the Corporate Future. John Wiley and Sons: New York.

Author:    Anupindi R, Chopra S, Deshmukh SD, Van Mieghem JA, Zemel E 
Year:    2006
Title:     Managing business process flows. Principles of operations management, 2nd edn. Pearson Education, Upper Saddle River

Author:    Argyris, C. 
Year:    1982
Title:    , Reasoning, Learning, and Action, Jossey-Bass, San Francisco, CA.

Author:    Arthur, W.B. 
Year:    1999
Title:    , "Complexity and the economy", Science, Vol. 284 No. 5411, pp. 107-9.

Author:    Anderson, P. 
Year:    1999
Title:    , 'Complexity theory and organization science', Organization Science, Vol. 10 No. 3, pp. 216-32.

Roundy S., M. Strasser, and P. K. Wright, Powering Ambient Intelligent Networks. Springer Berlin Heidelberg, 2005.

Author:    Julie Ann Stuart, Jane C. Ammons and Laura J. Turbini 
Year:    1999
Title:     A Product and Process Selection Model with Multidisciplinary Environmental Considerations, March�April 1999; Operations Research, 47: 221�234.

Author:    [17] Kaplan, R.S. 
Year:    1983
Title:    , "Measuring performance - a new challenge for managerial accounting research", The Accounting Review, Vol. 58 No. 4,1983, pp. 686-705.

Author:    22. Kauffman S 
Year:    1995
Title:    . At Home in the Universe: The Search for the Laws of Self-Organization and Complexity, 1st edn. Oxford University Press: New York, USA.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed to find and append or insert on SAME line

Hi, $ cat f1 My name is Bruce and my surname is I want to use SED to find “Bruce” and then append “ Lee” to the end of the line in which “Bruce” is found Then a more tricky one…. I want to INSERT ….a string… in to a line in which I find sometihng. So example $ cat f2 My name is... (9 Replies)
Discussion started by: Imre
9 Replies

2. Shell Programming and Scripting

Find keywords, and append at the end of line

Task: Find keywords in each line, and append at the end of line; if not found in the line, do nothing. the code is wrong. how to make it work. thanks a lot. cat keywords.txt | while read line; do awk -F"|" '{if (/$line/) {print $0"$line , ";} else print;}' outfile.txt > tmp ... (9 Replies)
Discussion started by: dtdt
9 Replies

3. Shell Programming and Scripting

Stuck on a text find and append task

Hi, Bit of a tricky one for first post and hoping someone can help me out here. I've got some code that I'm trying to consolidate by taking the first line where it says "OUTPUT", remove the : and append it after a space where the are occurences of ".csv", and then take the next occurence of... (3 Replies)
Discussion started by: owl4528
3 Replies

4. Shell Programming and Scripting

How to append timestamp in the filenames using find?

Hi, How to change the filenames with timestamp in sub folders I have the following code to select the records. find . -type f -name '*pqr*' -ctime 1 -print The following is the example app_root_dir="/`echo $ScriptDir | cut -d'/' -f2`" $app_root_dir/../BadFiles directory uvw.bad... (3 Replies)
Discussion started by: bobbygsk
3 Replies

5. UNIX for Dummies Questions & Answers

Find diff between two patterns in two files and append

Hi, I'm a newbie at programming in Unix, and I seem to have a task that is greater than I can handle. Trying to learn awk by the way (but in the end, i just need something that works). My goal is to compare two files and output the difference between the two. I've been reading, and I think I... (5 Replies)
Discussion started by: legato22
5 Replies

6. Shell Programming and Scripting

Find string in a file and append character

Hi Experts, Is there a way to find a string in a file then append a character to that string then save the file or save to another file. Here is an example. >cat test.txt NULL NULL NULL 9,800.00 NULL 1,234,567.01 I want to find all NON NULL String and add a dollar sign to those... (9 Replies)
Discussion started by: brichigo
9 Replies

7. Shell Programming and Scripting

[Solved] Find and append line to output

Hi All, I am trying to write a shell script but not getting desired output. What i am trying to do. 1.I want to use find command command and then use it xargs/exec to append the find output.But i am not getting desired output here is what i am trying to do #find init*.ora -exec `echo... (4 Replies)
Discussion started by: sahil_shine
4 Replies

8. Shell Programming and Scripting

sed to find first appearance and append string

I have a file like below #GROUP A belongs to Asia GROUP A jojh hans local admin GROUP A gege fans michel jing jong #GROUP U belongs to USA GROUP U jeff goal hello world My requirement is to grep for first apperence of GROUP A which is not commented and append my name to end of file.... (12 Replies)
Discussion started by: vkk
12 Replies

9. UNIX for Dummies Questions & Answers

Find, copy, and append into one file

Hi, I am trying to do something relatively easy, but am having some trouble getting it to work. I have multiple files called "distances.log" in numerous subdirectories and sub-subdirectories within a directory. I would like the contents of each of these "distances.log" files to be appended to a... (2 Replies)
Discussion started by: euspilapteryx
2 Replies

10. Shell Programming and Scripting

find, if exists then append for file with same name

I will have to process multiple files with same name everyday. My requirement is: If on a certain day I see that filename.txt exists then the contents of the filename.txt would be added/append to the former file contents.Each time it sees the file the content would be added.But the header ... (8 Replies)
Discussion started by: RubinPat
8 Replies
Login or Register to Ask a Question