I have file test1.txt file, i am trying to read variable which is enclosed in double quotes and starting with hyphen for eg: “-color”. i trying to use this grep command cat test1.txt | grep getParm | sed ‘s/getParm(/ /;s/&/ /;s/,/ /;s/”/ /g’ | awk ‘{print $3}’ , where i am not able to read exact data for all variables
Tag: sed
get multiple words after a specific word of HTML using linux/unix scripting
i have a file ‘movie.html’ : I want to get multiple word with pipe delimited like this: I tried this code: but the output isn’t as my expectation please help me, i am still a beginner Answer Parsing html with regex is not advised for several reasons (see https://stackoverflow.com/a/1732454/12957340), but here is one potential solution:
Parse From Text File into String output
So I have a text file called employees.txt that looks like this… I’m trying to write a sed script that will read in the text file then output it in the format “< name > is a < gender >, and is < age > years old now.” I know I need to set the IFS=, but I’m stuck on
Is there a program that functions like printf with an entire file as input?
My use case is as follows. file.txt First arg: %s Second %s arg, Third %s Run prog file.txt “one” “$(ls dir1/dir2)” “three” Resulting in First arg: one Second file1 file2 file3 arg, Third three I first thought to use sed but that inevitably runs into problems when bash substitutions get read as format characters like this sed s/%1/$VAR/g -> sed
Sed to replace a speccificc part of line by argument in shell script based in line number
I have a script test.sh He has some arguments like : I made a while read loop to replace each specific part of a line (extractReplaceArgLine) with argument passed in shell script (Forest Cuba World Hello). Consider the file test.txt : So, the output would be : How can I do that ? Thanks ! Answer Use $1 to get
Sed to search regex pattern and remove line with above pattern
this is my file.txt content. Here I’m trying to search pattern text: ‘About’ and remove items:[{ line with the command as below: file.txt: Command: sed -n -i -E ‘/text: ‘About’/{n; $p; x; d}; x; 1!p; ${x;p;}’ file.txt but it seems to be not working. Is there any way to make it work to remove line above pattern? Thanks in advance.
Finding Duplicate rows based on a column in Unix File
I have a file of about 1 Million records. I need to extract the records which have different FName and LName for id. Input File The result that I want to see Any AWK or Sed command or script can help? Thanks Answer Using GNU awk for arrays of arrays: or if your input file is sorted by “id” as
How to match and cut the string with different conditions using sed?
I want to grep the string which comes after WORK= and ignore if there comes paranthesis after that string . The text looks like this : So, desirable output should print only : So far , I could just match and cut before WORK= but could not remove WORK= itself: I am not sure how to continue . Can anyone
How to speed-up sed that uses Regex on very large single cell BAM file
I have the following simple script that tries to count the tag encoded with “CB:Z” in SAM/BAM file: Typically it needs to process 40 million lines. That codes takes around 1 hour to finish. This line sed ‘s/.*CB:Z:([ACGT]*).*/1/’ is very time consuming. How can I speed it up? The reason I used the Regex is that the “CB” tag column-wise
Renaming sub-directories recursively to a new pattern in bash
I want to rename sub-directories to my new pattern but some results may be dangerous in my own script: For example if I use /tmp/etc as input argument I would have the nasty results in the first iteration: So in next iteration there will not be /tmp/etc to work at. The second problem in my script is when I use