Skip to main content

All Questions

Tagged with
0 votes
1 answer
986 views

Return list using git diff and grep

I'm using git diff to return the file names of files recently changed and i'm trying to pipe the returned file names into a grep expression that searches each file and returns the files that have &...
X13Theo's user avatar
0 votes
1 answer
226 views

create a directory for every file and generate "n" copies for each file

while I was looking for a solution for my files, I found something that is perfect, I include the answer here: How do I create a directory for every file in a parent directory but now, my problem is ...
edwin reyes's user avatar
0 votes
1 answer
109 views

Trying to move words from dictionary using grep command to append .txt file [closed]

Doing a project going for extra credit by making script to do work for me instead of me typing in commands over and over. I need to move several words from a file. Not just the words, but words ...
Jackson Putnam's user avatar
3 votes
2 answers
13k views

Using the grep command with an array of words

I've got a text file with some lines and saved the text file into an array using readarray -t array < Textfile The Text file contains e.g. the following: 123 456 789 Now I'd like to use the grep ...
X3nion's user avatar
  • 143
0 votes
2 answers
73 views

while reading lines from a file, need to print the previous line if matches found to given string using bash script

I have a file say file.txt and contents looks like below with more than 10000 lines. Wed May 27 15:41:29 PDT 2020 Entering directory : /aaa/bbb/ccc Wed May 27 15:42:30 PDT 2020 Entering ...
SRP's user avatar
  • 1
0 votes
2 answers
3k views

Bash if based on grep result gives "too many arguments" error?

So I am trying to tell if the machine has a battery, then run different commands based on whether or not it does. Here's what I have so far: upower -d >> /tmp/batstat if [ grep -F BAT0 /tmp/...
user5104897's user avatar
1 vote
1 answer
347 views

Search a string in files in the current directory, omit duplicates

Assuming I want to write a line which prints out lines which match a specific string without repeating duplicate lines .. I want to search for this string in the files of the current directory: grep ...
Sijaan Hallak's user avatar
1 vote
3 answers
2k views

remove files based upon diff of two text files

I have created two .txt files that look like: 5fba026dcf271c6fa174b9fc2fc1fefadf1370f9 ./.changeFiles/change/addImage1.change bb352fba5807f4d03ea11abb00e411b00ce38673 ./.changeFiles/change/...
Zak's user avatar
  • 13
5 votes
4 answers
6k views

How to count occurrences of all the words in all the files of a directory using grep? But with count incremented only once per word per file

I have already asked a similar question but people misunderstood what i was asking. I was asking how to generate a list of every word with a word count incremented only once per word per file. For ...
Cnvrsn's user avatar
  • 51
3 votes
2 answers
2k views

Extract csv files from path to multiple files in bash

I have a files multiple file path for backup purpose ,now i want to filter it based on ".csv " fromat. I have tried this. filesall=(/home/abc/allfiles/*) files=$((${filesall[@]}|grep -F ".csv")) ...
Aashu's user avatar
  • 791
26 votes
5 answers
71k views

Number of files containing a given string

How can I count the number of files (in a directory) containing a given string as input in bash/sh?
user avatar