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?

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!"
tate1615Asked:
Who is Participating?
 
pzurowskiConnect With a Mentor Commented:
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
 
pzurowskiCommented:
You have to escape "?" character.
FILES_TO_ADD=$(svn status | awk '^\?' {print $2}')

Open in new window

0
 
albuitraCommented:
With grep is more easy
FILES_TO_ADD=`grep ^\? status.log `
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
albuitraConnect With a Mentor Commented:
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
 
TintinConnect With a Mentor Commented:
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
 
pzurowskiCommented:
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
 
pzurowskiCommented:
Tintin, i assume that tate1615 needs those files for something more than simple add and commit...
0
 
tate1615Author Commented:
You guys rock!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.