Solved

Is there an awk or perl line I can use in a bash script to help automate the addition of files to an svn repo?

Posted on 2008-06-17
8
292 Views
Last Modified: 2013-12-16
When I use "svn status" in my directory:
It gives me a long list of files either preceeded by an M for "modified" or a question mark(?) for new files.

**Is there any way to add a line in a bash script that would extract only the filenames preceeded by the question mark?(new files)

Here is psuedo-what-I-want-to-do-o:
#!/bin/bash
cd /path/to/project
svn status >> status.log
FILES_TO_ADD= (INSERT MAGIC THAT EXTRACTS FILENAMES THAT NEED ADDING HERE!)
for file in $FILES_TO_ADD; do
svn add $file
done
svn commit -m "This is an awesome commit!"
0
Comment
Question by:tate1615
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Expert Comment

by:pzurowski
ID: 21807669
You have to escape "?" character.
FILES_TO_ADD=$(svn status | awk '^\?' {print $2}')

Open in new window

0
 
LVL 4

Expert Comment

by:albuitra
ID: 21807672
With grep is more easy
FILES_TO_ADD=`grep ^\? status.log `
0
 
LVL 3

Accepted Solution

by:
pzurowski earned 225 total points
ID: 21807702
with grep you will get a lot of "?" in $FILES_TO_ADD

of course that (my) code you can write so (i've forgotten about status.log file):
FILES_TO_ADD=$(awk '^\?' {print $2}' status.log)

Open in new window

0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 4

Assisted Solution

by:albuitra
albuitra earned 225 total points
ID: 21807795
Not
this is a test in linux
/home/abuitrago> cat test
? hola
adios
? 1
?2
3 ?
/home/abuitrago> grep ^\? test
? hola
? 1
?2
/home/abuitrago>
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 50 total points
ID: 21807866
Do you realise that you can simply do:

svn add *
svn commit -m "This is an awesome commit!"

Any files already added will just be ignored.
0
 
LVL 3

Expert Comment

by:pzurowski
ID: 21807913
both will not work... i've forgotten about slashes

Try such script:
#!/bin/bash
cd /path/to/project
svn status >> status.log
awk '/^\?/ {print $2}' status.log | while read file; do
   svn add $file
done
svn commit -m "This is an awesome commit!"

Open in new window

0
 
LVL 3

Expert Comment

by:pzurowski
ID: 21807923
Tintin, i assume that tate1615 needs those files for something more than simple add and commit...
0
 

Author Closing Comment

by:tate1615
ID: 31468149
You guys rock!
0

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question