Grep won't work. SOLVED

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
SteveM2020
Level 3
Level 3
Posts: 115
Joined: Thu Feb 27, 2020 9:22 pm

Grep won't work. SOLVED

Post by SteveM2020 »

Was going to do a command line tutorial on my laptop.
Tried $ grep "kenney" -r .
$ grep "Bob Sterling" -r .
$ grep "Reboot Alberta" -r .

Kenney doesn't exist. The other two do. This found nothing. Grep is installed. I don't know how to fix this. Tried the same commands using sudo too, but it didn't make any difference.

Code: Select all

steve@steve-HP-Pavilion-dv6-Notebook-PC:~/Desktop$ inxi -Fxxxrz
System:
  Kernel: 5.4.0-80-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 
  Desktop: Xfce 4.16.0 tk: Gtk 3.24.20 info: xfce4-panel wm: xfwm4 
  dm: LightDM 1.30.0 Distro: Linux Mint 20.2 Uma base: Ubuntu 20.04 focal 
Machine:
  Type: Laptop System: Hewlett-Packard product: HP Pavilion dv6 Notebook PC 
  v: 058B110000242B10000020100 serial: <filter> Chassis: type: 10 
  serial: <filter> 
  Mobo: Hewlett-Packard model: 1441 v: 67.33 serial: <filter> 
  BIOS: Hewlett-Packard v: F.28 date: 04/11/2011 
Battery:
  ID-1: BAT0 charge: 49.4 Wh condition: 49.4/49.4 Wh (100%) volts: 12.4/10.8 
  model: Hewlett-Packard Primary type: Li-ion serial: <filter> status: Full 
CPU:
  Topology: Triple Core model: AMD Phenom II P840 bits: 64 type: MCP 
  arch: K10 rev: 3 L2 cache: 1536 KiB 
  flags: lm nx pae sse sse2 sse3 sse4a svm bogomips: 11371 
  Speed: 800 MHz min/max: 800/1900 MHz Core speeds (MHz): 1: 800 2: 800 
  3: 800 
Graphics:
  Device-1: AMD RS880M [Mobility Radeon HD 4225/4250] 
  vendor: Hewlett-Packard driver: radeon v: kernel bus ID: 01:05.0 
  chip ID: 1002:9712 
  Device-2: AMD Park [Mobility Radeon HD 5430/5450/5470] 
  vendor: Hewlett-Packard driver: radeon v: kernel bus ID: 02:00.0 
  chip ID: 1002:68e0 
  Display: x11 server: X.Org 1.20.11 driver: ati,radeon 
  unloaded: fbdev,modesetting,vesa resolution: 1366x768~60Hz, 1366x768~60Hz 
  OpenGL: renderer: AMD RS880 (DRM 2.50.0 / 5.4.0-80-generic LLVM 12.0.0) 
  v: 3.3 Mesa 21.0.3 compat-v: 3.0 direct render: Yes 
Audio:
  Device-1: AMD SBx00 Azalia vendor: Hewlett-Packard driver: snd_hda_intel 
  v: kernel bus ID: 00:14.2 chip ID: 1002:4383 
  Device-2: AMD Cedar HDMI Audio [Radeon HD 5400/6300/7300 Series] 
  vendor: Hewlett-Packard driver: snd_hda_intel v: kernel bus ID: 02:00.1 
  chip ID: 1002:aa68 
  Sound Server: ALSA v: k5.4.0-80-generic 
Network:
  Device-1: Qualcomm Atheros AR9285 Wireless Network Adapter 
  vendor: Hewlett-Packard U98Z062.12 802.11bgn driver: ath9k v: kernel 
  port: 3000 bus ID: 03:00.0 chip ID: 168c:002b 
  IF: wlo2 state: up mac: <filter> 
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
  vendor: Hewlett-Packard driver: r8169 v: kernel port: 2000 bus ID: 04:00.0 
  chip ID: 10ec:8168 
  IF: enp4s0 state: down mac: <filter> 
Drives:
  Local Storage: total: 465.76 GiB used: 104.80 GiB (22.5%) 
  ID-1: /dev/sda vendor: Seagate model: ST9500420AS size: 465.76 GiB 
  speed: 3.0 Gb/s rotation: 7200 rpm serial: <filter> rev: HPM1 scheme: MBR 
Partition:
  ID-1: / size: 457.45 GiB used: 104.80 GiB (22.9%) fs: ext4 dev: /dev/sda1 
Sensors:
  System Temperatures: cpu: 71.0 C mobo: N/A gpu: radeon temp: 70 C 
  Fan Speeds (RPM): N/A 
Repos:
  Active apt repos in: /etc/apt/sources.list 
  1: deb https://typora.io/linux ./
  Active apt repos in: /etc/apt/sources.list.d/bashtop-monitor-bashtop-focal.list 
  1: deb http://ppa.launchpad.net/bashtop-monitor/bashtop/ubuntu focal main
  Active apt repos in: /etc/apt/sources.list.d/jami-main.list 
  1: deb https://dl.jami.net/nightly/ubuntu_20.04 jami main
  Active apt repos in: /etc/apt/sources.list.d/microsoft-edge-dev.list 
  1: deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main
  Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list 
  1: deb http://packages.linuxmint.com uma main upstream import backport #id:linuxmint_main
  2: deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
  3: deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
  4: deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
  5: deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
  6: deb http://archive.canonical.com/ubuntu/ focal partner
  Active apt repos in: /etc/apt/sources.list.d/signal-xenial.list 
  1: deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main
  Active apt repos in: /etc/apt/sources.list.d/slimbook-slimbook-focal.list 
  1: deb http://ppa.launchpad.net/slimbook/slimbook/ubuntu focal main
Info:
  Processes: 206 Uptime: 1h 03m Memory: 3.59 GiB used: 1.64 GiB (45.6%) 
  Init: systemd v: 245 runlevel: 5 Compilers: gcc: 9.3.0 alt: 7/9 
  Shell: bash v: 5.0.17 running in: gnome-terminal inxi: 3.0.38 
steve@steve-HP-Pavilion-dv6-Notebook-PC:~/Desktop$ 
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29459
Joined: Wed Jul 06, 2011 3:58 am

Re: Grep won't work.

Post by xenopeek »

SteveM2020 wrote: Wed Aug 04, 2021 2:48 pmKenney doesn't exist. The other two do. This found nothing. Grep is installed. I don't know how to fix this.
You're either not in right directory and the files containing the text "Bob Sterling" and "Reboot Alberta" are not in the directory or its subdirectories from which you're running the command.

Or you're in the right directory but the files containing the text "Bob Sterling" and "Reboot Alberta" are in a symlinked subdirectory. The -r flag you used doesn't follow symlinks, use -R flag with grep for that.

Or you wrote "Bob Sterling" and "Reboot Alberta" in the wrong case. If the files containing these texts have it as "bob sterling" and "reboot alberta" for example, you'd have to add -i flag to grep for case insensitive matching.

And FYI: -r / -R don't require a path if you want to search from the current directory. So you can leave off the final . (dot) argument to grep.
Image
vimes666
Level 6
Level 6
Posts: 1176
Joined: Tue Jan 19, 2016 6:08 pm

Re: Grep won't work.

Post by vimes666 »

If you do not give grep a location where to look, it will search the map you are in at the moment you execute the command.
I suspect you are in another directory than you think you are.

type cd ~
to go to your home directory and then try the grep commands again.
If you think the issue is solved, edit your original post and add the word solved to the title.
User avatar
xenopeek
Level 25
Level 25
Posts: 29459
Joined: Wed Jul 06, 2011 3:58 am

Re: Grep won't work.

Post by xenopeek »

vimes666 wrote: Wed Aug 04, 2021 4:02 pm type cd ~
to go to your home directory and then try the grep commands again.
Just cd is enough, that takes you to your home directory.
Image
SteveM2020
Level 3
Level 3
Posts: 115
Joined: Thu Feb 27, 2020 9:22 pm

Re: Grep won't work.

Post by SteveM2020 »

Thank you!
vimes666
Level 6
Level 6
Posts: 1176
Joined: Tue Jan 19, 2016 6:08 pm

Re: Grep won't work.

Post by vimes666 »

xenopeek wrote: Wed Aug 04, 2021 4:37 pm Just cd is enough, that takes you to your home directory.
Is that new or have I been typing a tilde for years for nothing?
If you think the issue is solved, edit your original post and add the word solved to the title.
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

Re: Grep won't work.

Post by rene »

vimes666 wrote: Wed Aug 04, 2021 5:12 pm Is that new or have I been typing a tilde for years for nothing?
Latter.
User avatar
Termy
Level 12
Level 12
Posts: 4254
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Grep won't work. SOLVED

Post by Termy »

If you're going to make tutorial videos or write such articles, please teach the standard syntax: grep [OPTS] MATCH FILE Refer to the synopsis of commands with man(1). The standard approach for command-line tools is to have options (flags, like -h), immediately after the command's name. Just because your approach works with grep(1), doesn't mean it's good form to teach it to people.

I think it's nice that you want to help people learn about the command-line, though.

I waited a couple of years (of dedicated use and learning) before I decided I was ready and knowledgeable enough to go teaching anything to other people, because I was fed up of the sheer volume of misinformation on the Internet; I don't regret it at all. If you're still in the early stages, you could instead share your journey, talking about things you've learned and mistakes you've made; that'd be very educational, and I wish we had more content like that online.
Last edited by Termy on Wed Aug 04, 2021 5:28 pm, edited 1 time in total.
I'm also Terminalforlife on GitHub.
vimes666
Level 6
Level 6
Posts: 1176
Joined: Tue Jan 19, 2016 6:08 pm

Re: Grep won't work.

Post by vimes666 »

rene wrote: Wed Aug 04, 2021 5:13 pm
vimes666 wrote: Wed Aug 04, 2021 5:12 pm Is that new or have I been typing a tilde for years for nothing?
Latter.
*sigh* thanks for the tip :)
If you think the issue is solved, edit your original post and add the word solved to the title.
User avatar
Termy
Level 12
Level 12
Posts: 4254
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Grep won't work.

Post by Termy »

vimes666 wrote: Wed Aug 04, 2021 5:21 pm ...
You might find help cd interesting — not in Bourne Shell derivatives ('/bin/sh').
I'm also Terminalforlife on GitHub.
Locked

Return to “Beginner Questions”