0

This is what I used:

for i in `find some -type f -name *.class` 

I got:

some/folder/subOne/fileOne.class
some/folder/subOne/fileTwo.class
some/other/sub/file.class

next, I would like to get rid of the "some/" for each value of $i. What command can I use? Do I HAVE to save them into a file first?

Thanks

2 Answers 2

1
$ i=some/other/sub/file.class
$ echo ${i#some/}
other/sub/file.class

Bash has simple string manipulation built in. See also ${i%.class} and the basename and dirname commands.

Sign up to request clarification or add additional context in comments.

Comments

0

awk :) http://en.wikipedia.org/wiki/AWK

EDIT: Oh and you can pipe commands together, so the output of the first command acts as the input for the second. Like 'cat example.txt | less' will output the file through a paginator.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.