Wednesday, May 8, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 2581  / 3 Years ago, tue, august 17, 2021, 4:22:14

I want to create an alias for grep like this:



grep argX ~/myfile


where argX is a parameter and myfile is always the same. How can I do this?


More From » command-line

 Answers
0

Alias don't supports parameter but you can write a small script and name it i.e. "filegrep"



#!/bin/bash
grep "$1" /home/youruser/myfile


Copy the script to /usr/bin and you can run it with filegrep argX in the console.


[#31007] Wednesday, August 18, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
llianconclad

Total Points: 65
Total Questions: 109
Total Answers: 127

Location: Mali
Member since Fri, Dec 3, 2021
2 Years ago
;