so I just decided to give zsh a go against Bash and came across some unhandy behaviour about which I couldn't find anything on the net:
If you do a ls | grep foo in Bash, the ls only contains one file per line so that grep only outputs the matching files.
Hi,
I have two files (ASCII text), pass.old and pass.new, I want to find all the lines in pass.new which don't appear in pass.old (most lines overlap)...
would like to write a bash program which if I type in the following:
-bash-4.1$ ./sample.sh path regex keyword
that will result something like that:
path/sample.txt:12
path/sample.txt:34
path/dir/sample1.txt:56
path/dir/sample2.txt:78
I have absolutely no idea how can I achieve this without using find or grep -r (but I can use grep/ sed/ awk) in bash...
I recently had trouble with some regex on the command-line, and
found that for matching a backslash, different numbers of
characters can be used. This number depends on the quoting used for
the regex (none, single quotes, double quotes).
I really don't look forward to having to do find/grep because the output, as returned by
find . -exec grep sometext {} \; -print
is just not very easy to read even when you dump it in a file.
Code:
#!/bin/bash
#...
for i in `ls -c1 /usr/share/applications`
do
name="cat $i | grep ^Name= | cut -d = -f2"
echo $name
#...
done
Now inside name as output is present:
Quote:
cat arandr.desktop | grep ^Name= | cut -d = -f2
...
while i want only the result of the command.
Ideally i would like obtain that information usin
curl -s $site | grep patern | awk -F "_" '{print $1}' >> $filegrep returns more than one line. So the above line works despite the lack of an array.awk takes them one by one like a good program and writes each to a file. All is well.
In Windows, in a Git Bash shell, I want to detect files that have DOS-style line endings. I thought this command would work but it doesn't:
find dir -type f -print0 | xargs -0 grep -l '^M$'
It doesn't work, even files that don't have CR line endings match.
I've never really thought about how the shell actually executes piped commands. I've always been told that the "stdout of one program gets piped into the stdin of another," as a way of thinking about pipes. So naturally, I thought that in the case of say, A | B, A would run first, then B gets the stdout of A, and uses the stdout of A as its input.