Using Shell Commands to Manipulate File Paths for Use as Arguments to Another Program
up vote
1
down vote
favorite
I can use find
like this to find a list of files:
find -type f -path "./src*" -name "*.php"`
For example:
./src/Superuseradmin/Model/Mapper/UUID.php
./src/Superuseradmin/Model/Mapper/Mapper.php
What I need to do, is read the filename:
./src/Superuseradmin/Model/Mapper/Mapper/UUID.php
And use it to generate PHPUnit test skeletons based on information contained in the path:
SuperuseradminModelMapperUUID
./test/Superuseradmin/Model/Mapper/UUIDTest.php
So that I can run this command for each one:
phpunit-skelgen.phar --test -- SuperuseradminModelMapperMyMapper
./src/Superuseradmin/Model/Mapper/MyMapper.php
./test/Superuseradmin/Model/Mapper/MyMapperTest.php
bash shell-script sed find
migrated from serverfault.com May 31 '13 at 17:25
This question came from our site for system and network administrators.
add a comment |
up vote
1
down vote
favorite
I can use find
like this to find a list of files:
find -type f -path "./src*" -name "*.php"`
For example:
./src/Superuseradmin/Model/Mapper/UUID.php
./src/Superuseradmin/Model/Mapper/Mapper.php
What I need to do, is read the filename:
./src/Superuseradmin/Model/Mapper/Mapper/UUID.php
And use it to generate PHPUnit test skeletons based on information contained in the path:
SuperuseradminModelMapperUUID
./test/Superuseradmin/Model/Mapper/UUIDTest.php
So that I can run this command for each one:
phpunit-skelgen.phar --test -- SuperuseradminModelMapperMyMapper
./src/Superuseradmin/Model/Mapper/MyMapper.php
./test/Superuseradmin/Model/Mapper/MyMapperTest.php
bash shell-script sed find
migrated from serverfault.com May 31 '13 at 17:25
This question came from our site for system and network administrators.
Unfortunately your example is inconsistent: "For example ./src/Superuseradmin/Model/UUID.php"; "file from find command: ./src/Superuseradmin/Model/Mapper/UUID.php".
– Hauke Laging
May 31 '13 at 11:06
@HaukeLaging have fixed that
– Gabriel Baker
May 31 '13 at 11:10
It's still inconsistent. In the explanation it'sUUID
, in the call exampleMyMapper
.
– Hauke Laging
May 31 '13 at 11:18
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I can use find
like this to find a list of files:
find -type f -path "./src*" -name "*.php"`
For example:
./src/Superuseradmin/Model/Mapper/UUID.php
./src/Superuseradmin/Model/Mapper/Mapper.php
What I need to do, is read the filename:
./src/Superuseradmin/Model/Mapper/Mapper/UUID.php
And use it to generate PHPUnit test skeletons based on information contained in the path:
SuperuseradminModelMapperUUID
./test/Superuseradmin/Model/Mapper/UUIDTest.php
So that I can run this command for each one:
phpunit-skelgen.phar --test -- SuperuseradminModelMapperMyMapper
./src/Superuseradmin/Model/Mapper/MyMapper.php
./test/Superuseradmin/Model/Mapper/MyMapperTest.php
bash shell-script sed find
I can use find
like this to find a list of files:
find -type f -path "./src*" -name "*.php"`
For example:
./src/Superuseradmin/Model/Mapper/UUID.php
./src/Superuseradmin/Model/Mapper/Mapper.php
What I need to do, is read the filename:
./src/Superuseradmin/Model/Mapper/Mapper/UUID.php
And use it to generate PHPUnit test skeletons based on information contained in the path:
SuperuseradminModelMapperUUID
./test/Superuseradmin/Model/Mapper/UUIDTest.php
So that I can run this command for each one:
phpunit-skelgen.phar --test -- SuperuseradminModelMapperMyMapper
./src/Superuseradmin/Model/Mapper/MyMapper.php
./test/Superuseradmin/Model/Mapper/MyMapperTest.php
bash shell-script sed find
bash shell-script sed find
edited Nov 21 at 21:37
Rui F Ribeiro
38.2k1475125
38.2k1475125
asked May 31 '13 at 10:44
Gabriel Baker
1084
1084
migrated from serverfault.com May 31 '13 at 17:25
This question came from our site for system and network administrators.
migrated from serverfault.com May 31 '13 at 17:25
This question came from our site for system and network administrators.
Unfortunately your example is inconsistent: "For example ./src/Superuseradmin/Model/UUID.php"; "file from find command: ./src/Superuseradmin/Model/Mapper/UUID.php".
– Hauke Laging
May 31 '13 at 11:06
@HaukeLaging have fixed that
– Gabriel Baker
May 31 '13 at 11:10
It's still inconsistent. In the explanation it'sUUID
, in the call exampleMyMapper
.
– Hauke Laging
May 31 '13 at 11:18
add a comment |
Unfortunately your example is inconsistent: "For example ./src/Superuseradmin/Model/UUID.php"; "file from find command: ./src/Superuseradmin/Model/Mapper/UUID.php".
– Hauke Laging
May 31 '13 at 11:06
@HaukeLaging have fixed that
– Gabriel Baker
May 31 '13 at 11:10
It's still inconsistent. In the explanation it'sUUID
, in the call exampleMyMapper
.
– Hauke Laging
May 31 '13 at 11:18
Unfortunately your example is inconsistent: "For example ./src/Superuseradmin/Model/UUID.php"; "file from find command: ./src/Superuseradmin/Model/Mapper/UUID.php".
– Hauke Laging
May 31 '13 at 11:06
Unfortunately your example is inconsistent: "For example ./src/Superuseradmin/Model/UUID.php"; "file from find command: ./src/Superuseradmin/Model/Mapper/UUID.php".
– Hauke Laging
May 31 '13 at 11:06
@HaukeLaging have fixed that
– Gabriel Baker
May 31 '13 at 11:10
@HaukeLaging have fixed that
– Gabriel Baker
May 31 '13 at 11:10
It's still inconsistent. In the explanation it's
UUID
, in the call example MyMapper
.– Hauke Laging
May 31 '13 at 11:18
It's still inconsistent. In the explanation it's
UUID
, in the call example MyMapper
.– Hauke Laging
May 31 '13 at 11:18
add a comment |
3 Answers
3
active
oldest
votes
up vote
4
down vote
accepted
Here is a quick attempt:
for i in `find -type f -path "./src*" -name "*.php"`; do echo phpunit-skelgen.phar --test -- `echo $i | sed -e 's!./src/!!' | sed -e 's/.php//' | sed -e 's/\//\/g'` $i `echo $i | sed -e 's!./src/!./test/!' | sed -e 's/.php/Test.php/'`;done
Given the following directory structure:
./src/Superuseradmin/Model/Mapper/MyMapper.php
./src/Superuseradmin/Model/UUID.php
It should output:
phpunit-skelgen.phar --test -- SuperuseradminModelMapperMyMapper ./src/Superuseradmin/Model/Mapper/MyMapper.php ./test/Superuseradmin/Model/Mapper/MyMapperTest.php
phpunit-skelgen.phar --test -- SuperuseradminModelUUID ./src/Superuseradmin/Model/UUID.php ./test/Superuseradmin/Model/UUIDTest.php
You can then save this to a script, check it and run. Watch out for spaces in file names. They will cause trouble.
Why should one ever use a pipeline of severalsed
instances immediately after one another instead of using onesed
instance with several-e
parameters? Furthermore one such line is an understanding nightmare. Compute values, assign them to variables, run commands with the variables (instead of the computing expressions).
– Hauke Laging
May 31 '13 at 11:28
Ended up using a variation of this, thanks.for i in `find -type f -path "./src*" -name "*.php"`; do mkdir -p `dirname $(echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!')`; phpunit-skelgen.phar --bootstrap test/Bootstrap.php --test -- `echo $i | sed -e 's!./src/!!' -e 's/.php//' -e 's!/!\\!g'` $i `echo $i | sed -e 's/.php/Test/' -e 's!./src/([[:alnum:]]*)!1Test!' -e 's!/!\\!g'` `echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!' -e 's/.php/Test.php/'`;done
– Gabriel Baker
May 31 '13 at 17:29
add a comment |
up vote
0
down vote
You create a shell script:
#! /bin/bash
find_path="./src/Superuseradmin/Model/Mapper/UUID.php"
# find_path="$1"
class="${find_path#./src/}" # Superuseradmin/Model/Mapper/UUID.php
class="${class%.php}" # Superuseradmin/Model/Mapper/UUID
class="${class////\}" # SuperuseradminModelMapperUUID
classhead="${class%\*}" # SuperuseradminModelMapper
classtail="${class#"$classhead"}" # UUID
class="${classhead}${classtail}" # SuperuseradminModelMapperUUID
# echo "class: '${class}'"
testfile="./test${find_path#./src}"
testfile="${testfile%.php}Test.php"
# echo "testfile: '${testfile}'"
echo phpunit-skelgen.phar --test -- "$class" "$find_path" "$testfile"
And make find
call this script:
find -type f -path "./src*" -name "*.php" -exec /my/script.sh {} ;
add a comment |
up vote
-1
down vote
Probably you want to do something like this:
cd src
for i in $(find . -type f -name '*.php'); do
SRC=$i
DST="../test/$(dirname $i)/$(basename $i php)Test.php"
echo "copy $SRC to $DST"
#cp $SRC $DST
done
for i in ...; SRC=$i
instead offor SRC in...
? Using a mix of two variables with the same content afterwards...?
– Hauke Laging
May 31 '13 at 11:30
I'm giving an idea to illustrate what's possible.Up to you to figure out the rest
– Marki
May 31 '13 at 11:36
You give an idea what is bad coding. Up to the others to correct that. I did that (at least point it out). This bad coding has nothing to do with "what's possible" with respect to the problem to be solved.
– Hauke Laging
May 31 '13 at 11:38
Yeah, your code is the best anyway. ;-)
– Marki
May 31 '13 at 12:17
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Here is a quick attempt:
for i in `find -type f -path "./src*" -name "*.php"`; do echo phpunit-skelgen.phar --test -- `echo $i | sed -e 's!./src/!!' | sed -e 's/.php//' | sed -e 's/\//\/g'` $i `echo $i | sed -e 's!./src/!./test/!' | sed -e 's/.php/Test.php/'`;done
Given the following directory structure:
./src/Superuseradmin/Model/Mapper/MyMapper.php
./src/Superuseradmin/Model/UUID.php
It should output:
phpunit-skelgen.phar --test -- SuperuseradminModelMapperMyMapper ./src/Superuseradmin/Model/Mapper/MyMapper.php ./test/Superuseradmin/Model/Mapper/MyMapperTest.php
phpunit-skelgen.phar --test -- SuperuseradminModelUUID ./src/Superuseradmin/Model/UUID.php ./test/Superuseradmin/Model/UUIDTest.php
You can then save this to a script, check it and run. Watch out for spaces in file names. They will cause trouble.
Why should one ever use a pipeline of severalsed
instances immediately after one another instead of using onesed
instance with several-e
parameters? Furthermore one such line is an understanding nightmare. Compute values, assign them to variables, run commands with the variables (instead of the computing expressions).
– Hauke Laging
May 31 '13 at 11:28
Ended up using a variation of this, thanks.for i in `find -type f -path "./src*" -name "*.php"`; do mkdir -p `dirname $(echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!')`; phpunit-skelgen.phar --bootstrap test/Bootstrap.php --test -- `echo $i | sed -e 's!./src/!!' -e 's/.php//' -e 's!/!\\!g'` $i `echo $i | sed -e 's/.php/Test/' -e 's!./src/([[:alnum:]]*)!1Test!' -e 's!/!\\!g'` `echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!' -e 's/.php/Test.php/'`;done
– Gabriel Baker
May 31 '13 at 17:29
add a comment |
up vote
4
down vote
accepted
Here is a quick attempt:
for i in `find -type f -path "./src*" -name "*.php"`; do echo phpunit-skelgen.phar --test -- `echo $i | sed -e 's!./src/!!' | sed -e 's/.php//' | sed -e 's/\//\/g'` $i `echo $i | sed -e 's!./src/!./test/!' | sed -e 's/.php/Test.php/'`;done
Given the following directory structure:
./src/Superuseradmin/Model/Mapper/MyMapper.php
./src/Superuseradmin/Model/UUID.php
It should output:
phpunit-skelgen.phar --test -- SuperuseradminModelMapperMyMapper ./src/Superuseradmin/Model/Mapper/MyMapper.php ./test/Superuseradmin/Model/Mapper/MyMapperTest.php
phpunit-skelgen.phar --test -- SuperuseradminModelUUID ./src/Superuseradmin/Model/UUID.php ./test/Superuseradmin/Model/UUIDTest.php
You can then save this to a script, check it and run. Watch out for spaces in file names. They will cause trouble.
Why should one ever use a pipeline of severalsed
instances immediately after one another instead of using onesed
instance with several-e
parameters? Furthermore one such line is an understanding nightmare. Compute values, assign them to variables, run commands with the variables (instead of the computing expressions).
– Hauke Laging
May 31 '13 at 11:28
Ended up using a variation of this, thanks.for i in `find -type f -path "./src*" -name "*.php"`; do mkdir -p `dirname $(echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!')`; phpunit-skelgen.phar --bootstrap test/Bootstrap.php --test -- `echo $i | sed -e 's!./src/!!' -e 's/.php//' -e 's!/!\\!g'` $i `echo $i | sed -e 's/.php/Test/' -e 's!./src/([[:alnum:]]*)!1Test!' -e 's!/!\\!g'` `echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!' -e 's/.php/Test.php/'`;done
– Gabriel Baker
May 31 '13 at 17:29
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Here is a quick attempt:
for i in `find -type f -path "./src*" -name "*.php"`; do echo phpunit-skelgen.phar --test -- `echo $i | sed -e 's!./src/!!' | sed -e 's/.php//' | sed -e 's/\//\/g'` $i `echo $i | sed -e 's!./src/!./test/!' | sed -e 's/.php/Test.php/'`;done
Given the following directory structure:
./src/Superuseradmin/Model/Mapper/MyMapper.php
./src/Superuseradmin/Model/UUID.php
It should output:
phpunit-skelgen.phar --test -- SuperuseradminModelMapperMyMapper ./src/Superuseradmin/Model/Mapper/MyMapper.php ./test/Superuseradmin/Model/Mapper/MyMapperTest.php
phpunit-skelgen.phar --test -- SuperuseradminModelUUID ./src/Superuseradmin/Model/UUID.php ./test/Superuseradmin/Model/UUIDTest.php
You can then save this to a script, check it and run. Watch out for spaces in file names. They will cause trouble.
Here is a quick attempt:
for i in `find -type f -path "./src*" -name "*.php"`; do echo phpunit-skelgen.phar --test -- `echo $i | sed -e 's!./src/!!' | sed -e 's/.php//' | sed -e 's/\//\/g'` $i `echo $i | sed -e 's!./src/!./test/!' | sed -e 's/.php/Test.php/'`;done
Given the following directory structure:
./src/Superuseradmin/Model/Mapper/MyMapper.php
./src/Superuseradmin/Model/UUID.php
It should output:
phpunit-skelgen.phar --test -- SuperuseradminModelMapperMyMapper ./src/Superuseradmin/Model/Mapper/MyMapper.php ./test/Superuseradmin/Model/Mapper/MyMapperTest.php
phpunit-skelgen.phar --test -- SuperuseradminModelUUID ./src/Superuseradmin/Model/UUID.php ./test/Superuseradmin/Model/UUIDTest.php
You can then save this to a script, check it and run. Watch out for spaces in file names. They will cause trouble.
answered May 31 '13 at 11:21
JDaly
561
561
Why should one ever use a pipeline of severalsed
instances immediately after one another instead of using onesed
instance with several-e
parameters? Furthermore one such line is an understanding nightmare. Compute values, assign them to variables, run commands with the variables (instead of the computing expressions).
– Hauke Laging
May 31 '13 at 11:28
Ended up using a variation of this, thanks.for i in `find -type f -path "./src*" -name "*.php"`; do mkdir -p `dirname $(echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!')`; phpunit-skelgen.phar --bootstrap test/Bootstrap.php --test -- `echo $i | sed -e 's!./src/!!' -e 's/.php//' -e 's!/!\\!g'` $i `echo $i | sed -e 's/.php/Test/' -e 's!./src/([[:alnum:]]*)!1Test!' -e 's!/!\\!g'` `echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!' -e 's/.php/Test.php/'`;done
– Gabriel Baker
May 31 '13 at 17:29
add a comment |
Why should one ever use a pipeline of severalsed
instances immediately after one another instead of using onesed
instance with several-e
parameters? Furthermore one such line is an understanding nightmare. Compute values, assign them to variables, run commands with the variables (instead of the computing expressions).
– Hauke Laging
May 31 '13 at 11:28
Ended up using a variation of this, thanks.for i in `find -type f -path "./src*" -name "*.php"`; do mkdir -p `dirname $(echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!')`; phpunit-skelgen.phar --bootstrap test/Bootstrap.php --test -- `echo $i | sed -e 's!./src/!!' -e 's/.php//' -e 's!/!\\!g'` $i `echo $i | sed -e 's/.php/Test/' -e 's!./src/([[:alnum:]]*)!1Test!' -e 's!/!\\!g'` `echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!' -e 's/.php/Test.php/'`;done
– Gabriel Baker
May 31 '13 at 17:29
Why should one ever use a pipeline of several
sed
instances immediately after one another instead of using one sed
instance with several -e
parameters? Furthermore one such line is an understanding nightmare. Compute values, assign them to variables, run commands with the variables (instead of the computing expressions).– Hauke Laging
May 31 '13 at 11:28
Why should one ever use a pipeline of several
sed
instances immediately after one another instead of using one sed
instance with several -e
parameters? Furthermore one such line is an understanding nightmare. Compute values, assign them to variables, run commands with the variables (instead of the computing expressions).– Hauke Laging
May 31 '13 at 11:28
Ended up using a variation of this, thanks.
for i in `find -type f -path "./src*" -name "*.php"`; do mkdir -p `dirname $(echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!')`; phpunit-skelgen.phar --bootstrap test/Bootstrap.php --test -- `echo $i | sed -e 's!./src/!!' -e 's/.php//' -e 's!/!\\!g'` $i `echo $i | sed -e 's/.php/Test/' -e 's!./src/([[:alnum:]]*)!1Test!' -e 's!/!\\!g'` `echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!' -e 's/.php/Test.php/'`;done
– Gabriel Baker
May 31 '13 at 17:29
Ended up using a variation of this, thanks.
for i in `find -type f -path "./src*" -name "*.php"`; do mkdir -p `dirname $(echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!')`; phpunit-skelgen.phar --bootstrap test/Bootstrap.php --test -- `echo $i | sed -e 's!./src/!!' -e 's/.php//' -e 's!/!\\!g'` $i `echo $i | sed -e 's/.php/Test/' -e 's!./src/([[:alnum:]]*)!1Test!' -e 's!/!\\!g'` `echo $i | sed -e 's!./src/([[:alnum:]]*)!./test/1Test!' -e 's/.php/Test.php/'`;done
– Gabriel Baker
May 31 '13 at 17:29
add a comment |
up vote
0
down vote
You create a shell script:
#! /bin/bash
find_path="./src/Superuseradmin/Model/Mapper/UUID.php"
# find_path="$1"
class="${find_path#./src/}" # Superuseradmin/Model/Mapper/UUID.php
class="${class%.php}" # Superuseradmin/Model/Mapper/UUID
class="${class////\}" # SuperuseradminModelMapperUUID
classhead="${class%\*}" # SuperuseradminModelMapper
classtail="${class#"$classhead"}" # UUID
class="${classhead}${classtail}" # SuperuseradminModelMapperUUID
# echo "class: '${class}'"
testfile="./test${find_path#./src}"
testfile="${testfile%.php}Test.php"
# echo "testfile: '${testfile}'"
echo phpunit-skelgen.phar --test -- "$class" "$find_path" "$testfile"
And make find
call this script:
find -type f -path "./src*" -name "*.php" -exec /my/script.sh {} ;
add a comment |
up vote
0
down vote
You create a shell script:
#! /bin/bash
find_path="./src/Superuseradmin/Model/Mapper/UUID.php"
# find_path="$1"
class="${find_path#./src/}" # Superuseradmin/Model/Mapper/UUID.php
class="${class%.php}" # Superuseradmin/Model/Mapper/UUID
class="${class////\}" # SuperuseradminModelMapperUUID
classhead="${class%\*}" # SuperuseradminModelMapper
classtail="${class#"$classhead"}" # UUID
class="${classhead}${classtail}" # SuperuseradminModelMapperUUID
# echo "class: '${class}'"
testfile="./test${find_path#./src}"
testfile="${testfile%.php}Test.php"
# echo "testfile: '${testfile}'"
echo phpunit-skelgen.phar --test -- "$class" "$find_path" "$testfile"
And make find
call this script:
find -type f -path "./src*" -name "*.php" -exec /my/script.sh {} ;
add a comment |
up vote
0
down vote
up vote
0
down vote
You create a shell script:
#! /bin/bash
find_path="./src/Superuseradmin/Model/Mapper/UUID.php"
# find_path="$1"
class="${find_path#./src/}" # Superuseradmin/Model/Mapper/UUID.php
class="${class%.php}" # Superuseradmin/Model/Mapper/UUID
class="${class////\}" # SuperuseradminModelMapperUUID
classhead="${class%\*}" # SuperuseradminModelMapper
classtail="${class#"$classhead"}" # UUID
class="${classhead}${classtail}" # SuperuseradminModelMapperUUID
# echo "class: '${class}'"
testfile="./test${find_path#./src}"
testfile="${testfile%.php}Test.php"
# echo "testfile: '${testfile}'"
echo phpunit-skelgen.phar --test -- "$class" "$find_path" "$testfile"
And make find
call this script:
find -type f -path "./src*" -name "*.php" -exec /my/script.sh {} ;
You create a shell script:
#! /bin/bash
find_path="./src/Superuseradmin/Model/Mapper/UUID.php"
# find_path="$1"
class="${find_path#./src/}" # Superuseradmin/Model/Mapper/UUID.php
class="${class%.php}" # Superuseradmin/Model/Mapper/UUID
class="${class////\}" # SuperuseradminModelMapperUUID
classhead="${class%\*}" # SuperuseradminModelMapper
classtail="${class#"$classhead"}" # UUID
class="${classhead}${classtail}" # SuperuseradminModelMapperUUID
# echo "class: '${class}'"
testfile="./test${find_path#./src}"
testfile="${testfile%.php}Test.php"
# echo "testfile: '${testfile}'"
echo phpunit-skelgen.phar --test -- "$class" "$find_path" "$testfile"
And make find
call this script:
find -type f -path "./src*" -name "*.php" -exec /my/script.sh {} ;
answered May 31 '13 at 11:24
Hauke Laging
55.1k1283130
55.1k1283130
add a comment |
add a comment |
up vote
-1
down vote
Probably you want to do something like this:
cd src
for i in $(find . -type f -name '*.php'); do
SRC=$i
DST="../test/$(dirname $i)/$(basename $i php)Test.php"
echo "copy $SRC to $DST"
#cp $SRC $DST
done
for i in ...; SRC=$i
instead offor SRC in...
? Using a mix of two variables with the same content afterwards...?
– Hauke Laging
May 31 '13 at 11:30
I'm giving an idea to illustrate what's possible.Up to you to figure out the rest
– Marki
May 31 '13 at 11:36
You give an idea what is bad coding. Up to the others to correct that. I did that (at least point it out). This bad coding has nothing to do with "what's possible" with respect to the problem to be solved.
– Hauke Laging
May 31 '13 at 11:38
Yeah, your code is the best anyway. ;-)
– Marki
May 31 '13 at 12:17
add a comment |
up vote
-1
down vote
Probably you want to do something like this:
cd src
for i in $(find . -type f -name '*.php'); do
SRC=$i
DST="../test/$(dirname $i)/$(basename $i php)Test.php"
echo "copy $SRC to $DST"
#cp $SRC $DST
done
for i in ...; SRC=$i
instead offor SRC in...
? Using a mix of two variables with the same content afterwards...?
– Hauke Laging
May 31 '13 at 11:30
I'm giving an idea to illustrate what's possible.Up to you to figure out the rest
– Marki
May 31 '13 at 11:36
You give an idea what is bad coding. Up to the others to correct that. I did that (at least point it out). This bad coding has nothing to do with "what's possible" with respect to the problem to be solved.
– Hauke Laging
May 31 '13 at 11:38
Yeah, your code is the best anyway. ;-)
– Marki
May 31 '13 at 12:17
add a comment |
up vote
-1
down vote
up vote
-1
down vote
Probably you want to do something like this:
cd src
for i in $(find . -type f -name '*.php'); do
SRC=$i
DST="../test/$(dirname $i)/$(basename $i php)Test.php"
echo "copy $SRC to $DST"
#cp $SRC $DST
done
Probably you want to do something like this:
cd src
for i in $(find . -type f -name '*.php'); do
SRC=$i
DST="../test/$(dirname $i)/$(basename $i php)Test.php"
echo "copy $SRC to $DST"
#cp $SRC $DST
done
answered May 31 '13 at 11:20
Marki
507210
507210
for i in ...; SRC=$i
instead offor SRC in...
? Using a mix of two variables with the same content afterwards...?
– Hauke Laging
May 31 '13 at 11:30
I'm giving an idea to illustrate what's possible.Up to you to figure out the rest
– Marki
May 31 '13 at 11:36
You give an idea what is bad coding. Up to the others to correct that. I did that (at least point it out). This bad coding has nothing to do with "what's possible" with respect to the problem to be solved.
– Hauke Laging
May 31 '13 at 11:38
Yeah, your code is the best anyway. ;-)
– Marki
May 31 '13 at 12:17
add a comment |
for i in ...; SRC=$i
instead offor SRC in...
? Using a mix of two variables with the same content afterwards...?
– Hauke Laging
May 31 '13 at 11:30
I'm giving an idea to illustrate what's possible.Up to you to figure out the rest
– Marki
May 31 '13 at 11:36
You give an idea what is bad coding. Up to the others to correct that. I did that (at least point it out). This bad coding has nothing to do with "what's possible" with respect to the problem to be solved.
– Hauke Laging
May 31 '13 at 11:38
Yeah, your code is the best anyway. ;-)
– Marki
May 31 '13 at 12:17
for i in ...; SRC=$i
instead of for SRC in...
? Using a mix of two variables with the same content afterwards...?– Hauke Laging
May 31 '13 at 11:30
for i in ...; SRC=$i
instead of for SRC in...
? Using a mix of two variables with the same content afterwards...?– Hauke Laging
May 31 '13 at 11:30
I'm giving an idea to illustrate what's possible.Up to you to figure out the rest
– Marki
May 31 '13 at 11:36
I'm giving an idea to illustrate what's possible.Up to you to figure out the rest
– Marki
May 31 '13 at 11:36
You give an idea what is bad coding. Up to the others to correct that. I did that (at least point it out). This bad coding has nothing to do with "what's possible" with respect to the problem to be solved.
– Hauke Laging
May 31 '13 at 11:38
You give an idea what is bad coding. Up to the others to correct that. I did that (at least point it out). This bad coding has nothing to do with "what's possible" with respect to the problem to be solved.
– Hauke Laging
May 31 '13 at 11:38
Yeah, your code is the best anyway. ;-)
– Marki
May 31 '13 at 12:17
Yeah, your code is the best anyway. ;-)
– Marki
May 31 '13 at 12:17
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f77809%2fusing-shell-commands-to-manipulate-file-paths-for-use-as-arguments-to-another-pr%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Unfortunately your example is inconsistent: "For example ./src/Superuseradmin/Model/UUID.php"; "file from find command: ./src/Superuseradmin/Model/Mapper/UUID.php".
– Hauke Laging
May 31 '13 at 11:06
@HaukeLaging have fixed that
– Gabriel Baker
May 31 '13 at 11:10
It's still inconsistent. In the explanation it's
UUID
, in the call exampleMyMapper
.– Hauke Laging
May 31 '13 at 11:18