I’m tryin to make a simple command to strip everything after a word, and echo the result.
Example:
street-ct-2a21340565364563563
thiswouldbedifferent-ss-3c63456345645635634
andthiscouldbesomethingelse-we-5d23453453634563456
removing everything expect the first section
Something like:
street-ct-221340565364563563
would result in:
street
This isn’t being saved in a txt file or anything, is it possible?
Edit: Assuming that the part you are trying to extract has variable length, this seems to be an even better solution:
In that snippet, we split the string whenever a “
-” occurs, and then assign the first part of the split string to the “part” variable. Additional examples on how to useforto split strings can be found here.According to this reference you could do something like this: