13
votes
8answers
1k views

Bash Script to repeat every word in a line?

I have a string like: dog cat bird whale And I want to get dog dog cat cat bird bird whale whale All the words are in the same line. Any idea?
0
votes
1answer
35 views

How to locate files within my computer containing strings of text

What I am trying to do: I am trying to locate files with in the directory \\xxxx that contain strings of text DSN=, Server=, UID=, Pwd=, Password=. The files do not have to contain every single ...
0
votes
2answers
54 views

How do different operators deal with a given string

I want to read two strings as parameters to bash script, these strings are meant to be extensions, then I want to replace the extension of files with the first extension to the second extension. The ...
0
votes
2answers
727 views

How to concat String, File Contents, and String in bash script?

I have a file which contains only one line $> cat file.txt apple,orange,cat,dog I need to append two String to it and assign it to a variable, one in front and another in the end, so that it ...
0
votes
1answer
63 views

GNU Screen - String Escapes

Can somebody please explain or point me to good tutorial about "String Escapes" used in ~/screenrc. I am playing with $PS1 and ~/.screenrc. While $PS1 seems pretty clear (colors, conditions, escape ...
0
votes
1answer
529 views

how to replace unknown substring of line with sed

I want to replace a substring in a line, but I don't know what that substring is. I do know how the line starts though. For example, DNS1=[...to be replaced....]. I tried: sed -i ...
0
votes
2answers
307 views

Alias for recursive case insensitive search in current directory

How do I set an alias, such as "mysearch", which will search for a string recursively in the directory I'm standing in. It should be as below: mysearch "this table..." = find -type f -exec grep ...
0
votes
2answers
375 views

Search recursively for a string containing whitespaces

I want to search for "this table..." string under /home/myuser directory recursively, ie in all files under /home/myuser and in all directories and sub-directories under /home/myuser. /home/myuser ...
2
votes
3answers
1k views

Get LVM size using AWK?

I'm in need to find out the LVM size of image vm001. Let's say I have a LVM volume called /dev/VGgroup/vm001. Now using lvdisplay I can find out the size: --- Logical volume --- LV Name ...
4
votes
3answers
3k views

How to use grep to match domain names?

I have a list of urls like: hxxp://url.com/subpage.html hxxp://www.url2.com/index.php hxxp://subdomain.url3.com/somepage.php ... How can I use grep to match the domain names only? All the urls ...
3
votes
4answers
2k views

How to get the shortest string in a text file with shell

Assume I have a text file as below abcd aaaaaaa gfgk hahahahahahhahh gf Then gf would be returned.Any good ideas?