Questions tagged [strings]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
22 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
1answer
56 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 ...
0
votes
0answers
98 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 ...
0
votes
0answers
18 views

Variable fails to be set while using find $var

I have manually set all of the paths to verify that it's not the paths breaking anything, and I know that the file I am wanting it to find exists, and when the name is hard coded, it works - also if I ...
1
vote
1answer
71 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
1answer
533 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
1answer
2k 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
1answer
7k 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 ...
0
votes
1answer
906 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
3answers
8k 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
2answers
62 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
3answers
5k 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
1answer
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 ...
7
votes
2answers
12k 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 ...
7
votes
5answers
7k 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 ...
9
votes
8answers
13k 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 git@github.com:some-user/my-repo.git or https://github.com/some-user/my-repo.git What is the best way in ...
12
votes
2answers
61k 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
1answer
47 views

filling up a file with a record with escaped chars

I have this record of a csv: "0258327469@pippo.it","456281438","16274","782981244047720"," ","<table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"" align=""center"" style=""font-...
19
votes
4answers
23k 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 ...
1
vote
1answer
7k 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: ...
8
votes
6answers
13k 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 $...
5
votes
2answers
17k 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
1answer
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
2answers
2k 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
4answers
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
1answer
252 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
5answers
227 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 ...
2
votes
1answer
6k 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
6answers
9k 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 -...
43
votes
5answers
90k 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?