LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-21-2007, 04:55 AM   #1
sylvaticus
Member
 
Registered: Apr 2006
Posts: 49

Rep: Reputation: 15
BASH: rename an argument of the script


Hello, I have to rename the filename feeded to a script as CVS doesn't like absolute path..

here is the script (obviously is not working... )

Code:
#!/bin/sh
echo $1 | sed 's/\/data\/Projects\/regmas/\.\./' > $TEST
echo $TEST
cvs status $TEST | sed -n 's/^[ \]*Working revision:[ \t]*\([0-9][0-9\.]*\).*/\1/p'

I want feed "cvs status" with the translation operated by sed on the fist provided argument, so it will operate e.g. on "../src/main.cpp" instead of "/data/Projects/regmas/src/main.cpp"..
 
Old 05-21-2007, 06:16 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
I can't comment on the intend. The syntax however, is sometimes wrong, sometimes more complicated than needed, and sometimes less than needed:
Code:
#!/bin/sh
TEST="$(sed 's#/data/Projects/regmas#..#' <<<"$1")"
echo $TEST
cvs status "$TEST" | sed -n 's/^[ \\]*Working revision:[[:blank:]]*\([0-9][0-9\.]*\).*/\1/p'
Yves.
 
Old 05-21-2007, 08:20 AM   #3
sylvaticus
Member
 
Registered: Apr 2006
Posts: 49

Original Poster
Rep: Reputation: 15
Thumbs up

Quote:
Originally Posted by theYinYeti
I can't comment on the intend. The syntax however, is sometimes wrong, sometimes more complicated than needed, and sometimes less than needed:
Code:
#!/bin/sh
TEST="$(sed 's#/data/Projects/regmas#..#' <<<"$1")"
echo $TEST
cvs status "$TEST" | sed -n 's/^[ \\]*Working revision:[[:blank:]]*\([0-9][0-9\.]*\).*/\1/p'
Yves.
'thanks, working ;-)
 
  


Reply

Tags
bash, commandline, rename, sed


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script? how to rename files in random way? lefty.crupps Linux - Software 15 06-08-2014 03:47 PM
Help with Bash Script - Rename Multiple Files embsupafly Programming 16 04-02-2010 03:50 AM
bash script 'for each command line argument' true_atlantis Linux - Newbie 3 01-28-2009 01:51 PM
bash: make rename script traverse directories morrolan Programming 2 11-08-2006 10:52 AM
Bash script to traverse directory tree and rename files intramaweb Programming 3 10-08-2006 12:51 PM


All times are GMT -5. The time now is 06:30 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration