Skip to main content

All Questions

0 votes
2 answers
124 views

Remove and add at the same time with sed

I have an variable in my script which I want to change: read -p "Enter the name of city: " city if [[ $city =~ Liverpool ]]; then sed -i -e "/\$type\_of\_city =/ s/= .*/= ${city}/&...
sqr's user avatar
  • 17
0 votes
1 answer
109 views

sed's regex for replacement

I am creating the script which checks what is the user input and based on that this value is replaced in the file. So far I have (but it does not work): #!/bin/bash read -p "Type your domain: &...
sqr's user avatar
  • 17
-2 votes
2 answers
1k views

Generate strings from regular expression in bash

How in Bash to generate a string given by a regex expression and pipe it to another command? For example: > $RANDOM | regex "{abcdef\d}[8]" | grep "1{3}" | less I did not find ...
Aycon's user avatar
  • 99
0 votes
1 answer
5k views

add a new line after a specific string in a file? [duplicate]

Right now I'm using echo sed '/\Random/a \ newly added line' info.txt to append some text to a file but I also need to add text below a certain string let's say random, I know it is possible with ...
Nawaz Moin yaakuza's user avatar
0 votes
1 answer
2k views

RegEx to extract file paths from a logfile

I need to get the file paths from a log file. I thought I will try this with regex. A file path would look like this: 75/751234/751234V0001_test-tag1-tag02-75x75_01.jpg I'm not a pro in Regex, so I ...
Scamus's user avatar
  • 15
6 votes
8 answers
4k views

Use awk to delete everything after the ","

I have a variable, var, that contains: XXXX YY ZZZZZ\n aaa,bbb,ccc All I want is aaa in the second line. I tried: out=$(echo "$var" | awk 'NR==2{sub(",.*","")}' ) but I ...
Dark_Stoner's user avatar
0 votes
4 answers
6k views

How to extract a portion of an XML tag value in a Bash script

I have a XML file like this (A.xml) : <?xml version="1.0"?> <RunParameters xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-...
nstatam's user avatar
  • 529
0 votes
1 answer
163 views

how to use xargs to extract a list of names from IRC

Using the finch IRC client, I copy/pasted a list of names to names.txt for processing. Basically, the names are seperated by spaces. Many of the names will have special characters like "/" ...
Nicholas Saunders's user avatar
0 votes
3 answers
317 views

Regular expression for a string

Hi I have a md file containing the below string and I want to write a regular expression for this. Conditions The id will be anything. The type will be youtube,vimeo etc ID and type are mandatory ...
Meera Sebastian's user avatar
0 votes
2 answers
131 views

Print expression with [ ]

I have an input in form A[BCDE]GT. I would like my output to be: ABGT ACGT ADGT AEGT I have tried to use echo, printf, trying to find something that might work. Does anyone know some command that ...
Elena's user avatar
  • 1
1 vote
1 answer
650 views

How to replace special characters in BibTeX (e.g. {\'{o}} = ó) within a shell script?

Does anyone know of any utilities or have experience converting special characters in a BibTeX file to its proper unicode equivalent in a bash script? Trouble is I can't even find a full list of the ...
Avana Vana's user avatar
3 votes
1 answer
15k views

Find Duplicate/Repeated or Unique words spanning across multiple lines in a file

Problem Is it possible to print repeated words that are not unique and spanning across multiple lines? not just unique words within singular lines. Previous work There's this question which solves ...
om-ha's user avatar
  • 221
0 votes
2 answers
2k views

And operation and case insensitivity in awk regular expression?

I'm trying to match filenames that contain two text patterns but the matching process should ignore case. Neither of the following regular expressions work: Setting the awk variable 'IGNORECASE' to a ...
bit's user avatar
  • 1,166
-2 votes
1 answer
492 views

Bash Script general questions [closed]

The first part of what i am mucking around with simply creates a folder entitled command_manuals that contain text file copies of all the commands available at the bash shell, the filenames which are ...
Adam Ledger's user avatar
0 votes
3 answers
3k views

In a bash shell script, how to rename multiple files, keeping only the numbers and the extension of the original file names?

I have a directory with a bunch of files with names like this: generic name- dd -01 _.txt generic name- dd -02 _.txt generic name- dd -03 _.txt generic name- dd -04 _.txt And I want to rename all of ...
André Shevantes's user avatar

15 30 50 per page