Extract word seperated by slash /
I give a commond to find a file, eg:.
Code:
find -iname file.po Quote:
Quote:
Similarly the next line of template file should be Quote:
and so on |
You've already been exposed to sed wrt replacing things, for example here: http://www.linuxquestions.org/questi...0/#post4869683 and you've been at LQ long enough to know that you should show some effort yourself. So please show what you came up with.
|
1) To start with, let's get the proper syntax for find down:
Code:
find <start_dirs> <global_opts> <matching_opts> <actions> 2) The output of find is likely to be a list of files, not just one, so you really need run a shell loop on the output. And since filenames can include spaces, you need to be able to handle them safely. This means you need to use -print0 null separators. How can I find and deal with file names containing newlines, spaces or both? http://mywiki.wooledge.org/BashFAQ/020 3) You need to split the string itself into individual elements. While this can be done with something like sed, it's really easier to just use read with the appropriate IFS setting and output to an array (unless you can guarantee the number of levels you'll get, in which case you can use individual variables). Since you'll already be using it in the while loop mentioned above, this is the recommended option. And see here for more on what you can do with shell built-ins: How do I do string manipulations in bash? http://mywiki.wooledge.org/BashFAQ/100 |
All times are GMT -5. The time now is 07:23 AM. |