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
291 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSL/TLS - openssl troubleshooting 3 82
UM7 Stop Sending packets with GPS Sensor 1 45
VMware machine is not booting 6 129
subtract to time in .bash file 2 10
Online collaboration can help businesses be more efficient, help employees grow their skills and foster a team environment.
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifiā€¦
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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