Reputation: 29465
I want to display lines that contain "addUser" and "2012-08-03" strings together on the same line in a Linux file. How to do this?
Upvotes: 1
Views: 2429
Reputation: 2635
awk '/addUser/ && /2012-08-03/' < file
or
grep addUser < file | grep 2012-08-03
or
sed -n 's@addUser@&@p' < file | sed -n 's@2012-08-03@&@p'
or
ruby -e 'File.readlines( "file" ).each {|l| puts l if l =~ /addUser/ and l =~ /2012-08-03/ }'
Upvotes: 2
Reputation: 31
command in linux
echo "adduser 2012-08-03 " > data.txt
to see the contents of data.txt file type cat data.txt
or vi data.txt
Upvotes: 1