With what you have shown us there is little hope of us being able to help you.
You seem to be saying that you want to extract 14 characters starting in position 53 from the 11 character string "./blablabla". We have no idea whether you are expecting other characters to come from subdirectory names, or if you have wildcard characters in "blablabla" that you aren't showing us, or something else.
If you tell us what operating system you're using, what shell you're using, show us some actual samples of the pathnames being produced by the command find . -name blablabla (in CODE tags), and show us exactly what ln commands you hope to produce from those pathnames (in CODE tags); we would have a much better chance of coming up with something that might accomplish what you're trying to do. Note that an ln -s command needs two operands; not just one (and your sample code seems to be trying to only produce one).
Please help us help you.
This User Gave Thanks to Don Cragun For This Post:
Ah, yes I see. Your assumptions are right. I do expect a long string to be returned from find, and I do need to extract characters from that long path and pass them to the ln command.
I'm using a bash shell on CentOS Linux.
I think that command is more like what I need. Find blablabla and create a symlink in this directory with a prefix of part of it's path.
The moderator put my desired results in "code," in the original post which made the post quite confusing. In my opinion.
Each folder needs the unique characters from it's path because each directory "blablabla" will have the exact same name.
I don't think the code suggested by nezabudka will work. I don't see it extracting characters :53:14 and piping them to ln.
Hopefully, I've cleared things up a bit.
Thanks in advance.
Give us some data to work upon - input data and desired results.
Your find command will definitely NOT work. Parameter expansion can't be used the way you wrote it.
scribling
I showed a variant with a string variable from which you can extract any part of the substring
or change in this way LESS=+/"Parameter Expansion" man bash
Ah, yes I see. Your assumptions are right. I do expect a long string to be returned from find, and I do need to extract characters from that long path and pass them to the ln command.
I'm using a bash shell on CentOS Linux.
That is good to know and will help us give you suggestions that will work in your environment IF you give us some representative sample data to use to verify that we understand what you're trying to do and to verify that the code we suggest will produce the results you want.
Quote:
I think that command is more like what I need. Find blablabla and create a symlink in this directory with a prefix of part of it's path.
The code seems to be you're trying to extract 14 characters from the pathnames find finds, but your sample data shows that you only expect to get 9 characters. We can't come up with any sample data that will trim the 14 characters you could extract from any pathname that would create the 9 characters shown in the sample output you say you want to produce.
And, as has already been said three times before in this thread, the find utility does not perform variable expansions on pathnames it outputs as -exec primary operands. The above find command will attempt to link each found pathname to the literal name {:53:14} blablabla. I'm sure that isn't what you want, but your refusal to give us a self-consistent description of what you're trying to do and your refusal to give us representative sample data that you will be processing leaves us confused and only able to make wild guesses at what you really want to do.
Quote:
The moderator put my desired results in "code," in the original post which made the post quite confusing. In my opinion.
Each folder needs the unique characters from it's path because each directory "blablabla" will have the exact same name.
The moderator who added the CODE tags to post #1 in this thread for you did not in any way add any confusion to what you had in your original post. Not having CODE tags makes leading and trailing <space> and <tab> characters disappear from view and coalesces sequences of <space> and <tab> characters in the middle of a line to single <space> characters. If you had had sequences of <space>s in your sample output, the CODE tags would have made that clear for us and then we might have been able to make sense of your sample output. Unfortunately, with or without the CODE tags, your sample desired output doesn't fit the description of the problem you say you're trying to solve.
Note also that this is the first time you've said anything about blablabla being a directory. There is nothing in your find command that restricts the pathnames it returns to be pathnames of directories. I have no idea whether or not this might cause you problems with the results your code will produce, but if it is a constraint on the output you want to produce, it would have been helpful to know this up front.
Quote:
I don't think the code suggested by nezabudka will work. I don't see it extracting characters :53:14 and piping them to ln.
Hopefully, I've cleared things up a bit.
Thanks in advance.
Unfortunately, you haven't.
I'm guessing that nezabudka has come closest to guessing at what you're trying to do, but her code won't quite work for you yet. Hopefully, it is close enough that you can work out the rest. If not, you MUST give some concrete actual sample pathnames that the find command I showed you in post #2 in this thread produces as output AND show us the exact ln commands you hope to produce from each of those sample pathnames.
Please help us help you.
This User Gave Thanks to Don Cragun For This Post:
Hi ,
I have a requirement to read a file ( 5 fields , ~ delimited) and find the records which contain anything other than Alphabets, Numbers , comma ,space and dot . ie a-z and A-Z and 0-9 and . and " " and , in 2nd field. Once I do that i would want the result to have field1|<flag>
flag can... (2 Replies)
Hi All,
I have file which have looks like below
abc=${def}
def=${efg}
efg= "this is the actual value"
based on "abc" value I have to call "efg" value , Am using below lines but it is not working
#!/bin/bash
source file.txt
echo $abc
Please wrap all code, files, input &... (5 Replies)
Need command for position based replace:
I need a command to replace with 0 for characters in the positions 11 to 20 to all the lines starts with 6 in a file.
For example the file ABC.txt has:
abcdefghijklmnopqrstuvwxyz
6abcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz... (4 Replies)
Hi all,
I have a source config file with variables like so:
eth1_ip=192.168.1.99
eth2_ip=192.168.1.123
eth3_ip=172.16.1.1
I am trying to run a script which loops based on the number of eth interfaces on a machine and therefore modifies the variable it calls in the environment based on the... (5 Replies)
Hi all, I need help.
I have an input text file (input.txt) like this:
21 GTGCAACACCGTCTTGAGAGG 50
21 GACCGAGACAGAATGAAAATC 73
21 CGGGTCTGTAGTAGCAAACGC 108
21 CGAAAAATGAACCCCTTTATC 220
21 CGTGATCCTGTTGAAGGGTCG 259
Now I need to count A/T/G/C numbers at each character location in column... (2 Replies)
I am trying to find a specific set of characters in a long file. I only want to find the characters in column 265 for 4 bytes.
Is there a search for that? I tried cut but couldn't get it to work.
Ex. I want to find '9999' in column 265 for 4 bytes. If it is in there, I want it to print... (12 Replies)
sed -e "s// /g" old.txt > new.txt
While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Issue:
i have variable A which is an alias for variable B which is equal to "THIS IS A TEST"
when every i echo variable A i only get the alias name for variable B, NOT the contents of variable B.
HOSTNAME# echo $TESTIT
+ echo THIS IS A TEST
THIS IS A TEST
HOSTNAME# ls -l
total... (10 Replies)