Questions tagged [strings]
The strings tag has no summary.
31 questions
2 votes
1 answer
36k views
Removing specific characters from a string on ansible
I have the following - set_fact: test_result: " {{ htmlres.content | regex_search('http://website([0-9]+)', '\\1') }}" Using debug, this returns the following " '[01]'" Wanting ...
1 vote
1 answer
4k views
convert strings from mixed to upper case in windows batch scripting
Is there a way to convert strings from mixed to upper case in windows batch scripting? I am writing a batch file to create certain objects and grant user groups access to them. That is, I should issue ...
0 votes
0 answers
1k views
Split variable $name NGINX server (rtmp-module)
I need to split the $name variable from my nginx conf file. I got a $name that is something like "12345_stream". I need to split this and use the part before "_" (12345) inside the ...
0 votes
1 answer
105 views
Variables covered in b' ' in Python 3
I am sure this is a fairly noob question, I have googled, and cannot find a straight answer, but I may be asking the wrong thing... I am trying to make an Out Of Box Configuration script, and all the ...
1 vote
0 answers
3k views
BASH: No Such File or directory when comparing Strings
I am trying to create a script to compare an inputted string to an empty value. The logic works, but I keep receiving the following error: ./demo.sh: line 13: [[/var: No such file or directory Here ...
1 vote
1 answer
340 views
How to drop outgoing traffic based on matching string over HTTPS
I am managing a small shared hosting server. Today I received a complaint from my hosting provider that my server is sending out requests on wp-login.php pages of other websites elsewhere. I ...
0 votes
1 answer
971 views
Grepping a single line from iftop
iftop -t -L1 -s1 Output: iftop -t -L1 -s1 | grep "Total send and receive rate:" Output: How can I grep just the "Total send and receive state:" line?
0 votes
1 answer
6k views
How to whitelist User Agent string?
I'm trying to whitelist a very specific User Agent string in Nginx. The below examples demonstrate how to whitelist general types of browsers (eg mozilla or chrome), but the string I want to whitelist ...
-2 votes
1 answer
16k views
How to cut a string after a number of characters in unix? [closed]
How to delete all characters in one line after point with with sed? I have a file with multiple lines like this: 123456789 3483 98765432 56345 985745634 3469 67495735 87654 Now I want to delete all ...
0 votes
1 answer
1k views
How to remove string and replace with content found in text file using batch script or powershell
How to remove string and replace with content found in text file using batch script. test.txt Version: 4.5.0 Import: //MPackages/Project/config/abc.txt #head //Packages/...
4 votes
3 answers
9k views
Replacing a string in an XML with Powershell causes MALFORMED XML
I have a rather large XML file that I need to replace some connection strings within. I use the following code to replace the strings: $temp = Get-Content .\bigxmlfile.xml $temp.replace("STRING1","...
1 vote
2 answers
87 views
How to report filenames found by strings after being piped through grep?
I've been around *nix long enough to remember having done this in the past, and now those neural pathways are gone... I'm searching /usr/local/lib for files that contain img_convert because I'm ...
6 votes
3 answers
12k views
How to reset a tcp connection immediately on both ends on a certain condition using linux netfilter/iptables?
Dear Serverfault community, I have the following problem: I need to reset (disconnect) tcp connections on both network sides immediately if a certain string is encountered in the packet data. I don't ...
4 votes
1 answer
2k views
How to add an event/alert on Zenoss for a string type SNMP OID?
I have the status of a particular application being reported as string over SNMP. When everything is working as expected, that monitoring reports an empty string and when some of the data sources ...
8 votes
2 answers
15k views
Lowercase variable values in a Puppet template
In my puppet config I need to lowercase a variable value before using it in a template. How to achieve this? Is there a way to lowercase a variable value inside the puppet manifest? Do I need to do ...
6 votes
5 answers
8k views
How do I split a string against a character in BASH?
I would like to be able to split an authorization code by the - character so that I can operate on each segment individually. I do not want to use external binaries (awk, grep) - this is to be as ...
24 votes
10 answers
25k views
Extract repository name from GitHub url in bash
Given ANY GitHub repository url string like: git://github.com/some-user/my-repo.git or [email protected]:some-user/my-repo.git or https://github.com/some-user/my-repo.git What is the best way in bash ...
12 votes
2 answers
65k views
How to get lines that contain string in a file?
In Linux, How do I display lines that contain a string in a text file, such as: search "my string" file_name How do I make the search case sensitive/insensitive? And how do I also display the line ...
0 votes
1 answer
58 views
filling up a file with a record with escaped chars
I have this record of a csv: "[email protected]","456281438","16274","782981244047720"," ","<table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"" align=""center"" style=""font-...
21 votes
5 answers
31k views
Linux shell command to filter a text file by line length
I have a 30gb disk image of a borked partition (think dd if=/dev/sda1 of=diskimage) that I need to recover some text files from. Data carving tools like foremost only work on files with well defined ...
2 votes
1 answer
10k views
How to find a file that contains the specified string in FreeBSD?
I'm searching for the way to find a file that contains specified string text. It should be fast as possible but its not that important. I was reading the manual, and I've build something like that: ...
20 votes
8 answers
29k views
portable unix way to join strings with separator
Is there a portable unix shellscripting way of joining a number of strings together with a given separator, like so: $ strjoin --- foo bar baz quux foo---bar---baz---quux Sure I could use a $...
6 votes
2 answers
25k views
How do I get the last part of directory from a command line
How do I store the last part of directory in a variable? For example I have the following path: A\B\C\D, I want to store D in variable like file_name=D.
-2 votes
1 answer
2k views
Mass search / replace string from ssh?
I am in the process of selling a network of 60 sites, they all have adsense with the same publisher id (google_ad_client="pub-xxxxxxxxxxxxxxxx") in all the files in the /home/ folder. How can I do a ...
0 votes
2 answers
3k views
Allow connections to only a specific URL via HTTPS with iptables, -m recent (potentially) and -m string (definitely)
Let's say that, for example, I want to allow connections only to subdomain.mydomain.com; I have it partially working, but it sometimes gets in a freaky loop with the client key exchange once the ...
3 votes
4 answers
2k views
How to extract hostname from $(who am i)
I try to extract the hostname from the following string (created using who am i): username pts/0 2010-10-05 17:30 (www.example.com) I need a solution which also works if (www.example.com) is ...
3 votes
1 answer
274 views
problem with strings in script powershell sudo
im making a script like sudo, the idea is that the sudo function is going to run a scriptblock in elevation. I'm having trouble with the strings variables, that i pass in that scriptblock. Is like the ...
3 votes
5 answers
264 views
Strip a single line out of many files
I am trying to remove a string from many text files on one of our servers. The string is identical across all these files and I can run: grep -r -l 'string' to get the file list but I am stuck on ...
3 votes
1 answer
7k views
How to replace text string in any type file(for example binary and ...) and multiple files in linux?
I want to replace text string in any type file(for example perl,cgi,text,binary,js and ...) in multiple folder in linux. How do i do? Tanks.
3 votes
6 answers
12k views
How to replace a text string in multiple files in Linux
There are a variety of ways to replace one string of text with another across many files. Here are a few ways: using sed and find: sed 's/oldstring/newstring/' "$1" > "$1".new && find -...
59 votes
6 answers
150k views
Linux Command to find Strings in Binary or non ascii file
Is there any linux command to extracts all the ascii strings from an executable or other binary file? I suppose I could do it with a grep, but I remember hearing somewhere that such a command existed?