I am trying to check if the 9th character in a file on each line is a v and if so, then print the first word. I've tried a number of variations and am stuck !If it's possible to also check if character position 1 begins with a s in the same awk, that would make it cleaner instead of using egrep.
egrep '^s' file | nawk '{virtual=substr($0,9,1); if ($virtual=="v") {printf "%s", $1}}'
nawk: illegal field $(e)
input record number 1
source line number 1
Can anyone help me get the position of the first and last non-missing data characters (while allowing missing data characters in the middle of the sequence)? I'm sure it is a simple sed or awk command but I can't figure it out. I think I can produce the output file I want once I have figured those commands out.
My ultimate goal is to write a script that can make composite sequences from two or more non-overlapping sequences (e.g., the two sequences from NEOM). I may also want to merge sequences that partially overlap (e.g., those from TEST) but that would complicate things. Is this a logical first step for such a script or would you do it differently?
I have two table files with x (1st column) ,y (2nd column) coordinates and intensity (3rd column). I need to match these two tables and divide the intensities at the consecutive coordinates on the 3rd column. The problem is the size of the tables are not same and I want to ignore the lines if they are not in one of the other file.
In a bash-script, only the case if a regular expression does not match is relevant.herefore I used the exclamation mark !. But where to place it?
These two work fine, but are they equivalent? Code: if ! [[ $abc =~ $pattern ]]; then or Code: if [[ ! $abc =~ $pattern ]]; then Where is the ! placed more correct?
I need to add some text using sed before and after the matching pattern. Does any one have any clue?e.g.cat /my/file | sed -e "s/first pattern/New Pattern/g" . /my/file.bakNow I need a result like New Pattern
If I have a MySQL field called, say, "Occupation", which contains "Java Programmer" in it, I would like it to come up when I search for "Java", so that I can get to the other fields in the table. How do I do this?
i tried searching on google but found it difficult to say exactly what I was looking for.Task - Capitalise x number of letters at the start of words.eg. Original line - one.two.three.fourRevised line - One.Two.three.four (here only requiring 2 changes)Test data:
I'm trying to find out how to extract the string between the 2 <title> tags: <title>this is what i want</title>.I found lots of results but nothing I've tried works.. EG:$page =~ m/<title>($.)</title>/gism;
Is there a way, preferably in python or BASH, to rename files from a list? for instance, track1.mp3, track2.mp3 should be renamed to the names stored in a file listing song names. I have tried to loop a variable through directory listing and renamed them, only to find that filenames with spaces can't be assigned to a variable as a whole. To solve the problem above, I have tried the read command in BASH, which enables the program reading line by line from a list. However, It was failed to pipe the results from directory listing to the read command.
I have a question about sed programming, actually a one-liner for which I cannot find a solution, right now. I need to delete a line matching a specific pattern only if it is the last line. In practice, I would put together the following:
I've been hitting my head against a wall for awhile with this one:As the last part of some data analysis I performing I would to construct a matrix from a series of different files. These files have the format:
Quote:Originally Posted by topcatI would like to know how i can write a shell script to delete a line if a particular pattern exists?E.g. I have a text file with multiple lines. Say 1000s. in the following pattern.
If the patternusername@email.com exists then the line "username@email.com:149.0.3.4:1 should be deleted from the file.I have a very similar question but I need to delete one line in a file which matches one very precise instance of a string only. Let's assume I have a file composed of thousands of lines and let's call the file chap-secrets. Let's take the following sample entries:
Code: #USERNAME SERVER PASSWORD IP pp pptpd blahblah *
I have written a regular expression (tested in regexpal and regextester alpha something) with which I want to replace something like code...
but it only matches functions which occupy one line only, despite my tests showing multiple line matching in javascript testers online and using the m and s flags (which should make it multi line no?)
I am interested in the following problem: given a string (pattern) find a regexp which match this pattern. I will need this for a developing of an idea 'pattern based filtration'.
where variable would maybe be the output of grep from fileA. So can I store the output of grep in a variable to use it afterwards with awk ?
something like that:
Code: result=`grep prot. fileA` ; awk 'BEGIN { RS = "###" } /'$result'/' fileB > output but that doesn't work. I'm always getting the entire fileB.
The output of grep get stored in the variable, I verified that with echo. So there is something that I just don't get... It seems to me that the above line should work.
I was reading Kernighan Ritchie book chapter 4 which deals with character pointers.I am not able to understand following different type of declarations
Code: char aname[][15] = { "Illegal month", "Jan", "Feb", "Mar" }; char amessage[] = "now is the time";
i am compiling the following program in linux. it's in c language. after the compilation with gcc when i run the executable file. it asks for input. but when i enter a name. i prints "Segmentation fault" and then terminate the program. can you please help me.
I have a file with one line. I want to check whether the first character is TAB or space, how can i do this.? using "cut" wont as it "bypasses the tab and space characters"