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
286 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
8 Comments
 
LVL 3

Expert Comment

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

Open in new window

0
 
LVL 4

Expert Comment

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

Accepted Solution

by:
pzurowski earned 225 total points
Comment Utility
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
 
LVL 4

Assisted Solution

by:albuitra
albuitra earned 225 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Tintin, i assume that tate1615 needs those files for something more than simple add and commit...
0
 

Author Closing Comment

by:tate1615
Comment Utility
You guys rock!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Cobalt Digital Marketing began using the Scrum Framework development process in summer 2009.  We hired a consultant to train the teams, observe meetings, and answer questions. He recommended that we begin using one-week sprints for several reason…
You can provide a virtual interface for remote stakeholders in a SWOT analysis through a Google Drawing template. By making real time viewing and collaboration possible, your team can build a stronger product.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now