All Questions
31
questions
0
votes
1
answer
125
views
macOS|Unix combine multi-line .txt file into single line with no spaces? (no line breaks)
I've been looking around & I cannot seem to find a command or regex that will do a simple command of combing all linebreaks & spaces in a text file into one line. most of them either add some ...
1
vote
1
answer
4k
views
Regular expression to match opening double quote missing a ending double quote
I have a large (25 million rows) data file that is pipe (|) delimited. The data vendor provides files and I run automated jobs to load the files to a Redshift database and then process the data.
The ...
0
votes
1
answer
47
views
Find strings that do not appear in a repository
Problem: I have a moderately large repository (1000s of files, hundreds of thousands of lines).
I have a text file with ~5000 lines.
I need to find the lines in the text file that do NOT appear ...
0
votes
1
answer
1k
views
Assign expression to a variable
This code strips out any []. It works great
echo "127[.]0[.]0[.]1" | tr -d "[]"
I would like to do the same thing but with shell scripting. User would enter:
./test 127[.]0[.]0[.]1
Output should ...
4
votes
1
answer
4k
views
regular expression search within command less
Exactly what kind of regular expression search is supported by less (e.g. can I use \d+)?
man less isn't clear on that, and my primarily google on that didn't return much good hit either. Thx.
1
vote
1
answer
193
views
Delete files with regular expression with negation
Tried to create a script to delete files from the directory in a first script argument that does not contain a sequence of symbols in a second script argument. But It doesn't do a thing.
What I tried:
...
1
vote
3
answers
411
views
Unix grep finding file beginning with [pattern]
I would like to find files that begin with a particular pattern i.e. the first line of file should contain the pattern, and then print the first 10 lines of such file, is there a way to do that?
Is ...
0
votes
1
answer
129
views
Matching () with a Unix/Linux regex
I have a couple files with the name
(a).1
(a).2
...
(a).100
Since a lot of processing tools don't really like ( and ) in the filename I thought it best to rename them to a different name. I googled ...
0
votes
1
answer
133
views
Including and excluding in one regular expression
We're using HP SiteScope system at work to monitor logs and get alerts when a special string or combination of strings is caught.
There is one field where the regular expression that catches the ...
3
votes
3
answers
1k
views
Sed replace only in even numbered lines of a file when replace commands are written in a file
I have all the replace commands in a file (say replace.sed) and i use it with -f flag of sed (sed -f replace.sed InputFile). But now i ran into a condition where i need to apply these replace rules ...
2
votes
1
answer
88
views
find using regexp and echo matches
I have about 50 users in /home/ directory and I have cloned a git repository to everyone:
Executed at /home/ as root user:
find . -maxdepth 1 -type d ! -name . -prune -exec git clone /shared/repos/...
3
votes
2
answers
3k
views
How to comment out multiple line matching a regex using sed or awk
I have a file that contains this:
[...]
location /static {
...
multiple lines
...
}
[...]
location /static/ {
...
multiple lines
...
}
[...]
And I want to get:
[...]
# ...
1
vote
1
answer
89
views
Is it possible to sed -i from a text file to another text file?
I'm coding a shell script on my Debian box and there's a line on the script that needs to delete some emails from a textfile that is full of emails, like this:
sed -i '/[email protected]\|email02@...
1
vote
3
answers
877
views
Unix delete with find: Delete all files that are listed in a file
In my root directory, I have a couple folders named something like AA, BB, CC etc., each containing files in the format AA1001.txt, BB1002.txt etc.
In my root folder, I also have a file all_to_delete ...
5
votes
1
answer
708
views
Non-greedy regular expression to convert command tags
Background
Consider the following text:
There are three types of font families: serif, sans serif, and
teletype. To switch between these families, use <cmd>rm</cmd> for
serif, <cmd&...