Questions tagged [strings]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
18k 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 ...
Ress's user avatar
  • 45
0 votes
1 answer
2k 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 ...
Dirk Horsten's user avatar
0 votes
0 answers
934 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 ...
tidpe's user avatar
  • 201
0 votes
1 answer
81 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 ...
Kevin Rutan's user avatar
1 vote
0 answers
2k 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 ...
Reboot's user avatar
  • 11
1 vote
1 answer
239 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 ...
John's user avatar
  • 15
0 votes
1 answer
788 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?
JustAGuy's user avatar
  • 639
0 votes
1 answer
4k 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 ...
user421936's user avatar
-2 votes
1 answer
13k 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 ...
TCP's user avatar
  • 11
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/...
tipu's user avatar
  • 3
4 votes
3 answers
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","...
JustAGuy's user avatar
  • 639
1 vote
2 answers
65 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 ...
Alan's user avatar
  • 541
6 votes
3 answers
9k 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 ...
Jens Moser's user avatar
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 ...
Carlos Lima's user avatar
8 votes
2 answers
14k 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 ...
paweloque's user avatar
  • 267
7 votes
5 answers
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 ...
Jay Hellwig's user avatar
21 votes
9 answers
21k 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 ...
Justin's user avatar
  • 5,248
12 votes
2 answers
63k 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 ...
alwbtc's user avatar
  • 229
0 votes
1 answer
49 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-...
dierre's user avatar
  • 145
20 votes
4 answers
28k 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 ...
Li-aung Yip's user avatar
2 votes
1 answer
9k 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: ...
Cyclone's user avatar
  • 260
16 votes
7 answers
22k 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 $...
JanKanis's user avatar
  • 483
6 votes
2 answers
23k 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.
Mohammad AL-Rawabdeh's user avatar
-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 ...
jejasmin's user avatar
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 ...
The Consumer's user avatar
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 ...
t6d's user avatar
  • 517
3 votes
1 answer
255 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 ...
mjsr's user avatar
  • 181
3 votes
5 answers
235 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 ...
Manny T's user avatar
  • 68
2 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.
M.Rezaei's user avatar
  • 415
3 votes
6 answers
11k 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 -...
51 votes
5 answers
129k 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?
Ethan Heilman's user avatar