Grep : Filter/Move All The Lines Containing Not More Than One "X" Character Into A Text File
Hi All
It's me again with another huge txt files.
What I have:
- I have 33 huge txt files in a folder.
- I have thousands of line in this txt file which contain many the letter "x" in them.
- Some of them have more than one "x" character in the line.
What I want to achieve:
- Grab all the lines that has not more than one "x". In other words, I just want to have lines that only have one "x" character in it.
It doesn't just have to be using grep cause this isn't school project or challenge.
I've had used many grep command but still my knowledge is not good enough yet. I believe I also have to put "wc" command in this. [I don't know]
Last time I used wc, it was a successful failure. I tried to "mv" all that txt file names that has only one word into another directory & I screwed up big time So I worry "wc" might not work in this situation just like it doesn't work to search "directory" [Maybe it does, I just don't know]
So here is my slightest clue for this: [it doesn't work]
You say this is working perfectly, but this will add lines from your input files that do not contain any x characters as well as those that contain one x character. Your initial requirements were conflicted as to whether or not lines with no x characters should be copied.
Yes, I had noticed there are line without "x" is also included for the first command. At least that removed lines with double "x" or more.
And for that 2nd, it removed anything but lines with Only one "x".
I kinda chose first option as I noticed some lines without "x" seems to be what's important.
But I was wondering if there might be a command with such functionality though:
- It will grep 33 .txt files and find lines without repeated "x" and it will write it into individual 33 .txt output files in a different directory
I have the clue something like this:
BUT, it will do the execution in the same directory. [In other words, I am screwed as the output has same extension and file name ] Thank god I didn't do that
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Platform: Oracle Linux 6.3
From a log file, I want to grep all lines with the pattern "TNS-" but I want to skip those with the pattern "TNS-12514" . How can I do this ? (3 Replies)
I have a file that stores data in pairs of lines, following this format:
line 1: header (preceded by ">")
line 2: sequence
Example.txt:
>seq1 name
GATTGATGTTTGAGTTTTGGTTTTT
>seq2 name
TTTTCTTC
I want to filter out the sequences and corresponding headers for all sequences that are less... (2 Replies)
Hello everyone
Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried
sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Dear Sir,
I am having text file with no delimiter like below
RAGAV S S 12358 SALES EXECUTIVE 25000
RAJU R B 64253 SALES EXECUTIVE 28000
RUKMAN S 32588 SALES EXECUTIVE 40000
NARGUND S S 12356 ... (3 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi all,
can any one suggest me the script to grep multiple strings from ps -ef
pls correct the below script . its not working/
i want to print OK if all the below process are running in my solaris system. else i want to print NOT OK.
bash-3.00$ ps -ef | grep blu
lscpusr 48 42 ... (11 Replies)
Hi,
My input has much more lines, but few of them are below
pin(IDF) {
direction : input;
drc_pinsigtype : signal;
pin(SELDIV6) {
direction : input;
drc_pinsigtype : ... (3 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)