anyone know about shell scriping?
Ok, I have a file dictionary, in a text file. so i want to move all the letters that starts with A in a different file. So I grep the words, then I want to redirect the command using shell notation into a different file. How am i able to do that?
Like I want to move all the words that I have grepped into another file.
Using shell.
I'm using the C btw, like the mac terminal
I don't seem to be able to do it, I keep on saving an empty file.
> foo.txt
i keep on saving an empty file
what's the full command you're typing into the terminal? are you sure the grep isn't returning an empty file
grep -i '^[a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z]$' mywords
I get an output of words
but i want to redirect the words into a different file
grep -i '^[a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z]$' mywords >foo.txt
THANKSSSSSS
yay
how to use fgrep
to find a nine letter word
man fgrep because I dunno I'm assuming you can use the same regex of [a-zA-z] 9 times
in this file, and the other dictionary file
this is the grep syntax grep '<pattern>' file1 file2...filenames.... fgrep [a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z] mywords mywords2
how do i search for 9 letters words in my file, from the other dictionary file
would fgrep -i [a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z] mywords mywords2 not work?
nope
I need more than that. errors etc.
nothing happens lol
lol, what are the filenames?
try copying your original regex pattern like so: fgrep -i '^[[a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z]$' 9words mywords things to note: my thing didn't have single quotes or the ^/$
nothing happens aslo
uh try removing the extra bracket? this is a mess :/ fgrep -i '^[a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z][a-z]$' 9words mywords
i have already made a file that contains the words
so i need to somehow make a pipeline
use the |
to match the 9 letter words with the dictionary file
so you have a file of 9 letter words and you want to see which ones are in the dictionary?
which one matches
like the 9 letter word luminesce
matching with photoluminescence
that's a bit different, gimme a bit, do you have any idea how you'd start?
apparently fgrep
A couple of things. A single > creates a new file, zeroing the file if it exists. >> appends to the target file, in BASH, but probably not sh, it will create a file if needed. The pipe operator "|" pipes stdout from one command to stdin of another command. FWIW, I only use egrep. IMO, it's too much of a hassle to remember whether something is Basic Regular Expression syntax or Extended Regular Expression syntax. That can make your RE: egrep -i '^[a-z]{9}$' or egrep '^[[:alpha:]]{9}$' using character classes.
shell scripting is working with commads on unix and linux shells , like using ls -l to list files in linus
Join our real-time social learning platform and learn together with your friends!