0
votes
0answers
40 views

Can grep read filenames from partially formatted filesystem?

Quick Explanation I accidentally partially (ripped the cord out when it started) formatted an ext4 partition via Ubuntu Disk Utility GUI as ext4. Presumably via mkfs or mke2fs or however it does it ...
1
vote
2answers
59 views

How to save linux command?

I am using grep -r [^a-zA-Z0-9]myVariableName[^a-zA-Z0-9] -n JS_files/ as mygrep file grep -r [^a-zA-Z0-9]$1[^a-zA-Z0-9] -n JS_files/ and then sh mygrep myVariableName But then I lose the ...
2
votes
2answers
108 views

how to pass a flag as an argument to grep

I'm trying to pass -- as an argument to grep because the file I'm interested in contains -- within its text, like so grep -- file.txt but I cannot because grep sees -- as a flag. How do I pass -- ...
3
votes
1answer
4k views

Ubuntu Linux: find files between specific times?

I found an SO called using Find/Grep to search files between specific time of day Based on that and a Unix SE called Grep command to find files containing text string and move them I ended up with: ...
0
votes
1answer
923 views

Store grep result in variable

As above I'm running this grep command which works as it should but how do I store the returned value into a variable? cat data.txt | grep "" |cut -d\, -f1 I tried this but it didn't work: ...
0
votes
2answers
171 views

Trying to Grep Multiple Phone Numbers Around a Specific Time

I work in at a telecom company and in some cases I need to search for multiple numbers around a specific time. I am using Ubuntu sever 10.04. When I search for a call my normal expression is: grep ...
3
votes
5answers
1k views

Grep all files in a directory and print matches with filename

I have a list of log files that I create as part of a video encoding script that I wrote. I would like to search all of them and print out certain statistics from the encode - how fast they were ...
1
vote
3answers
4k views

Search for files and print their full path

ls -R /media/X | grep filename lets me search for file names, but it only prints the file name and not the directory it resides in. How can I print the file name and its directory?
1
vote
2answers
2k views

Get the most common appearing lines from file in Linux

I have a text file that has various words per line. How can I find the 12 most frequent appearing lines in the file and display them? I am not very good with scripting commands. If I could get the ...
7
votes
4answers
5k views

Ubuntu grep, find etc: “Permission denied” and “No such file or directory” output

When I grep or find something I always get annoyed by the "Permission denied" and "No such file or directory" notice, smth like that: johndoe@johndoe-desktop:/$ grep -rnP 'YII_CORE_PATH' ./ | grep -v ...
1
vote
1answer
244 views

How do I grep help output in linux?

When I use a switch that doesn't exist in commands such as lsof and ps there is a lengthy help menu that is returned. Instead of reading the whole thing I'd like to be able to grep it for the switch ...
2
votes
3answers
909 views

renaming files in a directory

I have files in a directory. The file names are constructed using a date timestamp notation, the file names are of the form: name_YYMM.csv I want to rename all such files using the following naming ...
2
votes
1answer
472 views

CLI: batch file rename — with CONTENT ?? (e.g. specific text mentioned in file)

I would like to batch rename files (*.txt) by inserting a number of the format 'RXR1234567' (RXR+7digits) [if such number (and ideally only one) is found in the text] at the front of the filename, ...
2
votes
1answer
173 views

finding surrounding lines with grep

I know how to use grep to output a line that matches a string. But what if I also want to output one line above every line containing a matching string, how do I do that?
0
votes
3answers
2k views

How to specify more than one string to ignore (grep command)

I am using grep to filter out directories I am not interested in like this: svn stat | grep -v data/charts | grep -v lib/model | grep -v web/pics It seems a bit "hacky". Is there a better way to ...
0
votes
6answers
4k views

Linux: list contents of sub directories with given name?

I'm using linux to analyze a windows directory structure. The structure is: /Documents and settings /username1 /My Documents ... /username2 /My Documents ... ... What command ...