Tagged Questions
1
vote
2answers
43 views
Weird zsh grep -P behaviour
I connect to server with PuTTY from Windows.
I have a long yet not touched (I suppose) by hands of local admin config:
$ cat /opt/jira/.subversion/config
...
### must be enabled, which is ...
11
votes
5answers
270 views
How to remove the (1) from filenames using the find command
I recently converted all of my FLAC files to a lower sampling rate of 44.1 kHz and bit depth of 24 bits (because iPhone/iPod don't support anything above that) using XLD on my Mac OS 10.7 (Lion).
...
2
votes
2answers
95 views
Detect pattern repetition in a file
I want to make sure a file follows the following pattern:
... ... ... foo ... foo_KO ... ...
... bar ... ... ... ... bar_KO ...
The file is extremely long, so, in other words, I want to make sure ...
3
votes
4answers
100 views
Recursively rename subdirectories that match a regex
I have a media server with a folder called Series. (/media/Expansion2/Series/)
In it, I have (surprise!) TV series. These are just the show names, e.g., /media/Expansion2/Series/The Big Bang Theory/
...
2
votes
1answer
56 views
Delete repeated words between brackets inline
Our input looks something like
2012-04-17 [GBPGBP]
2012-04-13 [GBP GBP]
2012-04-13 [GBP]
2012-04-11 [GBPGBP]
2012-04-11 [GBP GBP]
2012-04-10 [GBPGBP]
2012-04-06 [GBP GBP GBP]
2012-04-17 ...
3
votes
1answer
54 views
Character classes: construct my own
I want to construct my own character class in a script, then modify (and use) it, for example:
[:myclass:] contains a, *, \n (as linefeed) and [WHITESPACE].
I want to add all characters to ...
2
votes
1answer
70 views
remove trailing zeros in awk not working. syntax error
regex = "\\.*0+$";
subst = "";
system("echo "id "| awk '{sub(\\.*0+$," subst"); print}'");
It is giving the following error:
awk: cmd. line:1: {sub(\.*0+$,); print}
awk: cmd. line:1: ^ ...
2
votes
4answers
86 views
How to insert the content of a file into another file (if regexp) in shell/perl
File1 Contents:
line1-file1 "1"
line2-file1 "2"
line3-file1 "3"
line4-file1 "4"
File2 Contents:
line1-file2 "25"
line2-file2 "24"
Pointer-file2 "23"
...
3
votes
3answers
100 views
Extracting text from a text file in bash
I have a large text file that is all one line. In the text are several sections that looks like foo=12345 and I need to extract them all as separate lines, ignoring the rest of the file.
For ...
3
votes
2answers
112 views
Number of backslashes needed for escaping regex backslash on the command-line
I recently had trouble with some regex on the command-line, and
found that for matching a backslash, different numbers of
characters can be used. This number depends on the quoting used for
the regex ...
2
votes
1answer
154 views
grep and escaping a dollar sign
I want to know which files have the string $Id$.
grep \$Id\$ my_dir/mylist_of_files
returns 0 occurrences.
I discovered that I have to use
grep \$Id$ my_dir/mylist_of_files
Then I see that the ...
3
votes
2answers
126 views
Replace a substring of filenames in a directory
There exists a directory, which includes several levels of sub-directories. Under these directories, there are a set of files whose names include a common word, e.g, .cc. How can I replace the .cc ...
3
votes
3answers
162 views
In a regular expression, which characters need escaping?
In general, which characters in a regular expression need escaping?
For example, the following is not syntactically correct:
echo '[]' | grep '[]'
grep: Unmatched [ or [^
This, however, is ...
2
votes
3answers
48 views
expr help - managing strings
I need to take text like this:
A234321=http://www.google..... a normal URL
And pull out only the URL, getting rid of the first part. I think I can use expr to do it, but I can't figure out the ...
5
votes
2answers
365 views
How does a shell (bash, for example) expand regular expressions?
Assume that a directory has 100 files starting with the letter 'a'.
If I do a grep <some string> a* from the terminal, how will the shell handle this?
Will it expand the regular expression, ...