The tag has no wiki summary.

learn more… | top users | synonyms

3
votes
2answers
181 views

filename with no spaces from two command lines

I am running two Linux commands and I want to put the resulting values together in a filename with no spaces and a dot separating the two values. So far, I've got this: pid=`sudo dmidecode -s ...
2
votes
2answers
8k views

Bash shell script to locate and remove substring within a filename

I am trying to write a bash shell script in Mac OS X 10.6 (which is called by an Automator Action) to rename TV show DVD rips that I have named badly over the years. I want to remove part of the text ...
2
votes
1answer
722 views

Need help converting a string from a file into a date

I'm trying to read a string from a file and then convert it into a date but for some reason it's failing. I'm actually modifying a GeekTool Geeklet that's not working at the moment. It reads a file ...
7
votes
4answers
1k views

How do I find the overlap of two strings in bash?

I have two strings. For the sake of the example they are set like this: string1="test toast" string2="test test" What I want is to find the overlap starting at the beginning of the strings. With ...
4
votes
2answers
1k views

Utility to get binary representation from string?

Is there a simple utility like printf that'll give me a "binary representation", i.e. a string like "01010010", from an input string? It would need to support multi-byte encodings.
2
votes
3answers
861 views

Is there a tr for translating into longer strings?

tr is great for translating a set of characters to another set of characters. Sometimes, I want to translate a set of characters to a set of strings, e.g. all < and > to &lt; and &gt;. ...
2
votes
3answers
627 views

Collapse repeating characters

Is there a more Bashist way than echo "$PWD//" | sed -e 's#//\+#/#g' to replace repeating slashes with a single one? Thanks Steven D, now there's a fully working function to find the longest common ...
2
votes
4answers
16k views

how to concatenate strings in bash?

I need to concatenate 2 strings in bash, so that: string1=hello string2=world mystring=string1+string2 echo mystring should produce helloworld
6
votes
7answers
4k views

How to check if $PWD is a subdirectory of a given path

E.g. check if $PWD is a subdirectory of /home. In other words I'm searching for a bash string operation to check if one string starts with another.
2
votes
1answer
889 views

Array of string expanded to path?

Suppose I have the following initialization of bash array: my_array=( "/usr/bin" "/usr/lib/*.so" ) If I do iteration using: for array_item in ${my_array[@]} do ... done Then the ...