LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-04-2008, 08:17 AM   #1
smyrna
LQ Newbie
 
Registered: Dec 2008
Posts: 6

Rep: Reputation: 0
Help with bash script.


I am using svn to build an app on a daily basis. I have written a script that simplifies the process for me updates svn, builds, etc. I build it 3 different ways then tar the builds to 3 different files and puts them in "home/username/builds/todaysbuild/ which is all working great! except I have to move the files from "todaysbuild" to "Rev12345"

This is where I am stuck, I want the script create a folder of the revision number and move the files there. Currently the last line of the script is "svn info" which reads back to me.

URL: xxxxxx
Repository Root: xxxxxx
Repository UUID: xxxxxx
Revision: 12345
Node Kind: directory
Schedule: normal
Last Changed Author: xxxxx
Last Changed Rev: 12345
Last Changed Date: 2008-12-03 22:28:19 -0500 (Wed, 03 Dec 2008)


If there is a way to read the 4th line of the info after the ":" and make a folder named "Rev12345" and move the files there without user input that would be great. If it can not do it automatically I would not mind that much if the script asked me to enter in the revision number and then make a directory named Rev"what I typed" then move the files there
once the scripts creates the directory.

Last edited by smyrna; 12-04-2008 at 08:19 AM.
 
Old 12-04-2008, 08:39 AM   #2
odys
LQ Newbie
 
Registered: Mar 2006
Posts: 5

Rep: Reputation: 0
Hello,

With awk you can do:
... | gawk '/^Revision:/ {sub(/^Revision: /,""); print}'

Last edited by odys; 12-04-2008 at 08:40 AM.
 
Old 12-04-2008, 08:53 AM   #3
smyrna
LQ Newbie
 
Registered: Dec 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Sorry im kinda a newb what does gawk even do? I know it would take more than that line to do it. Could you give a longer example?
 
Old 12-04-2008, 09:15 AM   #4
unihiekka
Member
 
Registered: Aug 2005
Distribution: SuSE Linux / Scientific Linux / [K|X]ubuntu
Posts: 273

Rep: Reputation: 32
Quote:
Originally Posted by smyrna View Post
Sorry im kinda a newb what does gawk even do? I know it would take more than that line to do it. Could you give a longer example?
Type
Code:
man gawk
and you'll see all there is to know. Another option is Wikipedia or even better the GNU Awk User's Guide.

What do you mean "I know it would take more than that line to do it"? If you know how to do it, why ask? And if you don't know what gawk is, then how do you know that it's more difficult than that.

Anyway, the one-liner provided by odys uses a: pipe, that is, the output of whatever comes before is sent to that what comes after the "|". Before that could be the command to run your script; the output is then used by gawk. You can always use a similar strategy to make some new directory based on gawk's output. I guess you need to make a small script where gawk's output can be put in a variable. I don't know for sure, as I'm not at my linux box right now.

You could also have a look at grep or even sed instead of (g)awk.

Last edited by unihiekka; 12-04-2008 at 10:23 AM.
 
Old 12-07-2008, 11:26 PM   #5
smyrna
LQ Newbie
 
Registered: Dec 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unihiekka View Post
Type
Code:
man gawk
and you'll see all there is to know. Another option is Wikipedia or even better the GNU Awk User's Guide.

What do you mean "I know it would take more than that line to do it"? If you know how to do it, why ask? And if you don't know what gawk is, then how do you know that it's more difficult than that.

Anyway, the one-liner provided by odys uses a: pipe, that is, the output of whatever comes before is sent to that what comes after the "|". Before that could be the command to run your script; the output is then used by gawk. You can always use a similar strategy to make some new directory based on gawk's output. I guess you need to make a small script where gawk's output can be put in a variable. I don't know for sure, as I'm not at my linux box right now.

You could also have a look at grep or even sed instead of (g)awk.
I know i can man gawk! I nicely asked how to do it in my OP. I know what a pipe is, but he put ...| i dont know where he wanted me to put it. maybe you could actually help and put the whole command as thats what i asked for. if i wanted to read manuals i would not ask here.
 
Old 12-08-2008, 12:48 AM   #6
SqdnGuns
Senior Member
 
Registered: Aug 2005
Location: Pensacola, FL
Distribution: Slackware64® Current & Arch
Posts: 1,092

Rep: Reputation: 174Reputation: 174
Read and you shall learn.....................
 
Old 12-08-2008, 03:31 PM   #7
smyrna
LQ Newbie
 
Registered: Dec 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Thumbs down

Quote:
Originally Posted by SqdnGuns View Post
Read and you shall learn.....................
And this is why Linux will never be Main Stream by the average user!! I would have had an answer on a Windows Batch /Mac Applescript forum days ago. This is so typical in the linux community.

Q. How do i do this?
A. Read the manual.

so annoying....

I didn't ask for a GD manual command. If no one wants to actually help just don't answer. Thanks for nothing and waisting my time and others who search the forum's for something similar time.

Can a mod just close this or remove it so others don't do a search for bash script and get this garbage non helpful thread?
 
Old 12-08-2008, 04:44 PM   #8
hasanatizaz
Member
 
Registered: Nov 2007
Location: Pakistan
Distribution: Redhat and Debian
Posts: 317
Blog Entries: 1

Rep: Reputation: 35
You're welcome
 
Old 12-08-2008, 05:32 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by smyrna View Post
if i wanted to read manuals i would not ask here.
You have gotten some good help here---and very quickly, too (1st response less thatn 30 minutes after the thread was opened.)

Most people here do their best to give useful advice within their personal time constraints. Sometimes all we have time for is: "Awk will do that---check the man page". Another day, you'll get a tome.

We don't alwasy assume that a newcomer has read the man page (or even that he/she knows what a man page, but we do assume a willingness to look at the man page after being pointed there.

Last edited by pixellany; 12-08-2008 at 05:33 PM. Reason: error
 
Old 12-10-2008, 05:48 AM   #10
arunmathew1984
Member
 
Registered: Nov 2008
Posts: 31

Rep: Reputation: 15
Gawk is the tool that should help you out. You can read up on it here - http://www.gnu.org/software/gawk/

Linux Archive

Last edited by arunmathew1984; 12-20-2008 at 11:17 AM.
 
Old 12-10-2008, 05:51 AM   #11
arunmathew1984
Member
 
Registered: Nov 2008
Posts: 31

Rep: Reputation: 15
Please do keep in mind - All the people here who are helping you out are doing just that - "Helping". None of them are being paid (by you) to provide you with a solution.

Ideally - like "Morpheus" says in "The Matrix" - "I can only show you the way. It is upto you to take the path"
 
Old 12-10-2008, 12:08 PM   #12
SqdnGuns
Senior Member
 
Registered: Aug 2005
Location: Pensacola, FL
Distribution: Slackware64® Current & Arch
Posts: 1,092

Rep: Reputation: 174Reputation: 174
I think the OP is a "drive by" poster..................

Has one question and then bails.
 
Old 12-10-2008, 05:58 PM   #13
smyrna
LQ Newbie
 
Registered: Dec 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by SqdnGuns View Post
I think the OP is a "drive by" poster..................

Has one question and then bails.
I would stay if people posted anything useful, again more posts to read about gawk! I asked a question on how to do something and still not an answer on how to actually do it! Just read a man or info page.

CAN ANYONE ACTUALLY HELP ME WITH A WAY TO DO IT? OR SHOULD I FIND ANOTHER FORUM THAT ANSWERS QUESTIONS?

Last edited by smyrna; 12-10-2008 at 06:03 PM.
 
Old 12-10-2008, 06:12 PM   #14
SqdnGuns
Senior Member
 
Registered: Aug 2005
Location: Pensacola, FL
Distribution: Slackware64® Current & Arch
Posts: 1,092

Rep: Reputation: 174Reputation: 174
Quote:
Originally Posted by smyrna View Post
I would stay if people posted anything useful, again more posts to read about gawk! I asked a question on how to do something and still not an answer on how to actually do it! Just read a man or info page.

CAN ANYONE ACTUALLY HELP ME WITH A WAY TO DO IT? OR SHOULD I FIND ANOTHER FORUM THAT ANSWERS QUESTIONS?
With that attitude and unwillingness to LEARN, don't let the door hit you in the arse on the way out. FFS............
 
Old 12-10-2008, 07:18 PM   #15
malaprop
LQ Newbie
 
Registered: Dec 2008
Location: TX
Distribution: Ubuntu 8.10
Posts: 26

Rep: Reputation: 16
The second post really does tell you everything. The RTFM suggestion was really to help you better understand WHY it works.

my system uses "awk"

the "...|"
... in this context means...your code
... = svn info

svn info | gawk...

I'm sure you're right, you likely would have gotten a more explicit answer faster on a windows forum, but in linux, there's a certain amount of sophistication assumed.

We are on the average, very very willing to help, but you need to pick up the reins at some point too.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 04:11 AM
Strange if statement behaviour when using bash/bash script freeindy Programming 7 08-04-2008 06:00 AM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 11:33 AM
Bash script to create bash script jag7720 Programming 10 09-10-2007 07:01 PM
[bash] having trouble debugging this bash script. jons Programming 4 02-08-2007 06:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration