Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
1 vote
1 answer
153 views

For context, I have some experience with Unix and basic commands, but I'm seriously struggling to conceptualize more complex manipulations of files. Essentially, I have this command I want to run from ...
avery's user avatar
  • 11
1 vote
3 answers
162 views

Why does this Perl Regex one-liner not make the full result upper case using the \U modifier? I expect MY_NICE_WORD. $ perl -pe 's/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/\U$1_$2\E/g' <(...
Jonathan Komar's user avatar
0 votes
1 answer
136 views

I try to figure out how to batch rename files using Fish so that filenames like image1.png and image10.png will be replaced with image001.png and image010.png, that is, to pad numbers with leading ...
jsx97's user avatar
  • 1,387
-1 votes
3 answers
178 views

I have a hard time figuring out how to remove duplicate but incomplete strings of text. No success using perl, awk or sed. I need to transform: a b a b c a b c d a b c d e a b c d x a b c d z into a ...
Simon Ante's user avatar
1 vote
1 answer
269 views

I am reading Software Design for Flexibility (SDF). Exercise 2.10 asks to implement the translator for both BRE and ERE. The book uses grep to test the translated string like (a.c) in ERE to capture ...
An5Drama's user avatar
  • 173
0 votes
1 answer
153 views

I want to use inotifywait to run code upon the creation of a file with a known fixed filename. This answer correctly explains that I cannot run inotifywait directly against a file that does not yet ...
jaimet's user avatar
  • 466
-1 votes
1 answer
171 views

In a shell script, I'm reading user input into a variable. Before I can do anything with it, I need to confirm if the input is a 4-digit number. If not, I want to exit the program without doing ...
Rishikesh Negi's user avatar
2 votes
2 answers
1k views

I encounter the following sed command in make's manual. sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' And it has the following effect (this is an example in the manual): main.o : main.c defs.h # is turned into:...
liginity's user avatar
  • 143
1 vote
1 answer
280 views

I am a bit confused about using regex in ranger (Arch Linux). I have a folder of files that look like this: 'sometexthere - I. - sometexthere' 'sometexthere - II. - sometexthere' 'sometexthere - III. -...
mor3dr3ad's user avatar
3 votes
2 answers
680 views

Is there any special bash reserved characters in bash regex expression? ex: eg: if [[ $url =~ ^https:\/\/www\.youtube\.com\/playlist\?(.+&)?list= ]]; then echo "URL matches the regex"; ...
Nor.Z's user avatar
  • 133
3 votes
1 answer
727 views

I have a command mapping ("ESC-P") in my .vimrc which underlines the current line, leaving whitespace or # intact. map ^[p :.t.^M:s/[^[:space:]#]/-/g^M If I run this on a line of text, it ...
Swordgeek's user avatar
-2 votes
4 answers
271 views

I am using gawk to parse the output of macos' /usr/bin/time into CSV format as shown below. The problem is that gawk is returning the 'involuntary context switches' value for 'voluntary context ...
jonathannah's user avatar
1 vote
1 answer
271 views

Some folders on macOS have custom icons that are stored in a file named Icon?, where the ? is actually a CR character, and only prints as "?" in most cases (in Terminal and Finder). But when ...
Thomas Tempelmann's user avatar
0 votes
0 answers
32 views

I am trying out the example 6.8 Testing with Regular Expressions from Bash Cookbook. I am reproducing the example here. My folder contents are as, $ ls Ludwig Van Beethoven - 01 - Allegro.ogg Ludwig ...
Saravana's user avatar
  • 193
0 votes
2 answers
1k views

How can I tell xdg-open to open, say, YouTube URLs in a specific app, but use my default browser for all other URLs?
Geremia's user avatar
  • 1,250
0 votes
2 answers
104 views

I have a file that contains the same pattern multiple times. I am trying to get sed to perform a series of operations only for the second occurrence of that pattern. The file looks like this: pattern ...
Felipe Evaristo's user avatar
0 votes
1 answer
301 views

Is there a pdf viewer that allows me to search its text by a regex expression? In case that I haven't found one, I am thinking about extracting the text and layout from a pdf file by less my.pdf > ...
Tim's user avatar
  • 107k
1 vote
1 answer
282 views

In Gnome's Text Editor (gnome-text-editor aka gted from the gnome-text-editor Debian package), I cannot get replacement of starting lines (-) at newlines by \item. I escape the item but does not work....
Léo Léopold Hertz 준영's user avatar
1 vote
2 answers
56 views

I have the following text in a file: #1713251479 sh lowbat.sh #1713251495 nvim lowbat.sh #1713252186 sh lowbat.sh and I want to put the Unix timestamp inline with the command like this: #1713251479 ...
ReYuki's user avatar
  • 33
-1 votes
1 answer
117 views

I'm trying to add the following to my .bashrc: cpu_info() { top -b -n1 | grep Cpu(s) | awk '{print $2 + $4}' } but bash is telling me: bash: .bashrc: line 131: syntax error near unexpected token `...
Mathew's user avatar
  • 243
0 votes
1 answer
85 views

I wanted to extract from a text all capitalized words that do not start a sentence or follow a period. I managed to do it with a combination of sed and grep but got stuck for a while with grep's ...
Pikko's user avatar
  • 16
0 votes
1 answer
194 views

Any suggestions? I read: Escape Sequences (The GNU Awk User’s Guide) Representative Example $ Filesystem='/dev/mapper/vgubuntu-Media' $ FilesystemRegex="$(echo "${Filesystem}" | sed &...
Porcupine's user avatar
  • 2,176
1 vote
1 answer
411 views

I would like to match a hexadecimal address of fixed length using a regex pattern in sed. For example: 0x000000010b2e993c 0x is always present followed by the sixteen-character hexadecimal number. ...
Max MacLeod's user avatar
0 votes
3 answers
775 views

I am trying to find and replace all lines in a text file that start with a single space and then any characters. Finally got the regex to work on grep grep -E '^ .*$*' Contacts.vcf >> t.txt Then ...
atclaus's user avatar
  • 101
1 vote
1 answer
109 views

I'm using these two codes below. ls -lap . | grep -v "/$" ls -lap . | grep -v "/" These two give me different outputs in some cases. What does $ mean in that context?
shersher's user avatar
0 votes
1 answer
164 views

Sorry if this is a repeat or basic question but it is hard to search for a ™. I'm writing a script to remove weird characters from file names. How come the trade mark symbol ™ matches [^a-z] ??? $ ...
codywohlers's user avatar
0 votes
1 answer
143 views

I try to understand how to use the find command with regular expressions (macOS 14.4.1, Zsh 5.9). I have a directory with files such as note-red.png, note-yellow.png, (and other colors), folder-red....
jsx97's user avatar
  • 1,387
0 votes
1 answer
592 views

Suppose I have a script containing something like VAR=${VAR1%.*} I'm looking for a command along the lines of rg "${.*%" to find it, but I can't get anywhere near. all of these fail rg &...
njamescouk's user avatar
-1 votes
5 answers
116 views

I have a file as following: example.txt -1 15 1 0 0 11 -1.0000E+001 1.0000E+001 -1.0000E+001 2 0 0 11 1.0000E+001 1.0000E+001 ...
Honza S.'s user avatar
  • 101
-1 votes
1 answer
61 views

bind -p |grep -E "\\e.\":" work but bind -p |grep -E "\\e\\C-.\":" don't work I tried a lot of combination
user3634569's user avatar
0 votes
2 answers
190 views

AFAIK the \b metasequence indicating "word boundaries" is not supported in bash: if [[ $foo =~ .*\bWORD\b.* ]]; then Are there reasons why this is not supported? Imagine I write a patch/...
guettli's user avatar
  • 1,589
0 votes
1 answer
56 views

After using rsync --itemize-changes -i --recursive --checksum --dry-run to compare the contents of two drives, I got this kind of result: 2024/03/12 08:31:01 [15248] .d Backups/Phone/Pictures/...
thomas's user avatar
  • 116
2 votes
5 answers
469 views

I have a .txt file which is a collection of numbers. It looks like this: [...] 6 2 7 999 8 105 9 78 10 45 11 6666 [...] up to a 4-digit index. Now I want to import the numbers as a list in python. ...
Lereu's user avatar
  • 133
2 votes
1 answer
131 views

Hello everyone and thanks for your support! I'm facing a problem while using REGEX inside a bash script through =~ operand. Environment: GNU bash, version 4.1.7(1)-release (powerpc-ibm-aix5.1.0.0) ...
omar.c's user avatar
  • 23
-4 votes
4 answers
583 views

I am trying to find a string in a web page downloaded w/ curl. I am using grep to find the string matching a regular expression pattern. Following is the string I am trying to find: ./download/file....
Seamus's user avatar
  • 3,904
-1 votes
5 answers
222 views

I have a lot of markdown files that contains something like this: * header A - item 1 - item 2 ** sub-header A1 ** sub-header A2 * header B - item 1 - item 2 ** sub-header B1 ** sub-...
GhostOrder's user avatar
0 votes
3 answers
109 views

Consider my humble hello.html file, edited with mighty ed: $ ed hello.html 28 ,p <title>Hello world!</title> What's your general approach to edit inside that title HTML tag (bonus if you ...
mbigras's user avatar
  • 3,512
0 votes
1 answer
658 views

I'm building an ansible playbook to copy a checklist from this file and moving it to another file. I'm relatively new to ansible. Originally, I used the Copy plugin but saw Fetch may be more up my ...
shottypop's user avatar
0 votes
2 answers
186 views

This SE answer made me realize I can exclude directories using regular expressions with grep. But it's not working for me when using |: results=$(grep --color=always -rnF "$searchTerm" . --...
wyc's user avatar
  • 143
1 vote
5 answers
162 views

I'm working with a file that looks like the following, containing with over 50,000 lines of gene IDs followed by their sequence: gene_A:3342234 CTCTTTCTTTTACGCCT gene_A:1244-5205 CTCTTTCTTTTACGCCT ...
bryophyta's user avatar
1 vote
6 answers
304 views

I am trying to create a Regular Expression that will match a string of digits that is 6 or 7 digits long. [0-9]{6,7} This works but i dont want a match in strings that are longer than 7 digits. Please ...
pt-t's user avatar
  • 25
3 votes
2 answers
275 views

I inherited a body of code where "command macros" are used in place of the underlying command to be run, e.g., $TR is used in place of tr. I want to use sed to convert the command macros ...
FKEinternet's user avatar
0 votes
1 answer
954 views

Title basically says it all, but I can't figure it out for the life of me and getting confused by bash regular expression matching. This is the if statement I have in my bash script, but it keeps ...
geckels1's user avatar
  • 173
6 votes
1 answer
341 views

I'm totally mystified why I can't print this range with ed when there are two ranges—see file2.tf file—; but I can print when there is only one range—see file1.tf file—and I can print with the gsed (...
mbigras's user avatar
  • 3,512
0 votes
1 answer
89 views

I have this question since time ago, and I'm not able to understand it. In the sample config file for Suricata drop rules, drop.conf, appears this sample line: # Rules matching specifiers in this file ...
Ecofintech's user avatar
0 votes
1 answer
409 views

I have a file mac-hosts containing MAC addresses and their associated host names: e4:5f:01:21:79:01 PF3 e4:5f:01:21:79:03 PF3-BR0 e4:5f:01:21:79:be PF2 e4:5f:01:21:79:c0 PF2-BR0 I want to get a count ...
FKEinternet's user avatar
2 votes
2 answers
210 views

Given bash environment variable settings : $ declare -g bs=$'\\' bsbs=$'\\\\' q="'"; This Regular Expression will correctly match a sequence of single quote-("'")-ed text , where ...
JVD's user avatar
  • 115
1 vote
1 answer
54 views

PIN A 1 1:3 0:8 0 0:0 PIN B 1 1:0 0 0:0 Z Z:0 PIN C 1 1:3 0:8 0 0:0 Z Z:0 I would like to change the content on PIN A & PIN C only without affecting PIN B to 0 0:3 Z 0:3 Can't seem to find a ...
JSL's user avatar
  • 11
0 votes
2 answers
182 views

I am writing a shell script to convert some DokuWiki pages to MediaWiki format and vice versa. I'm having some troubles with footnotes. There is a plugin for DokuWiki that adds extended features to ...
Daniel's user avatar
  • 432
3 votes
1 answer
1k views

I try to use regex such as ^ to find the start of the line in the gedit editor in Ubuntu 22.04 but it doesn't work. Also for $ as the end of the line. Other regular expressions such as \n,\d,\s work ...
trilisser's user avatar
  • 133

1
2
3 4 5
57