Can't find a result with The Silver Searcher at a certain depth - ack

I'm getting some odd behaviour with The Silver Searcher that I just discovered when looking for a line in my code base. In the root folder, I call
% ag branding_black_with_bundles
% ag --depth -1 branding_black_with_bundles
and get nothing. However, when I call the same with ack, I get the result
% ack branding_black_with_bundles
app/database/seeds/test_seeder/dumps/Swf.php
88: array("id"=>907,"title"=>"branding_black_with_bundles","original_filename"=>"original_filename","created_by_id"=>2,"created_at"=>"2013-09-14 18:16:12","updated_at"=>"2013-06-15 04:14:50"),
When I cd down one directory closer, I find it:
% cd app
% ag branding_black_with_bundles
database/seeds/test_seeder/dumps/Swf.php
88: array("id"=>907,"title"=>"branding_black_with_bundles","original_filename"=>"original_filename","created_by_id"=>2,"created_at"=>"2013-09-14 18:16:12","updated_at"=>"2013-06-15 04:14:50"),
What is up? Is it a bug, or am I missing some kind of setting?

My bad! It turns out the file with the result is specified under .agignore, and to avoid it I must use ag -u branding_black_with_bundles, and/or remove from the .agignore file.
As Doon said, it could well have been in .gitignore also, so if coming across this problem, best to check there also I think.

Related

iTerm2 now starts up listing profile configuration

Recently, when I load iTerm2 on my mac, it lists out the configuration of my profile (or possibly its something different).
This is what I see:
Last login: Tue Jun 21 19:54:38 on ttys000COLORFGBG='15;0'
COLORTERM=truecolor
COMMAND_MODE=unix2003
HOME=/Users/me
ITERM_PROFILE=Default
ITERM_SESSION_ID=w0t0p0:FD9764B1-4535-4FE2-932A-97AFD9D6C804
LANG=en_GB.UTF-8
LC_TERMINAL=iTerm2
LC_TERMINAL_VERSION=3.4.15
LOGNAME=me
OLDPWD=/Users/me
PATH=/usr/bin:/bin:/usr/sbin:/sbin
PWD=/Users/me
SHELL=/bin/zsh
SHLVL=1
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.u21pRFo1wk/Listeners
TERM=xterm
TERM_PROGRAM=iTerm.app
TERM_PROGRAM_VERSION=3.4.15
TERM_SESSION_ID=w0t0p0:FD9764B1-4535-4FE2-932A-97AFD9D6C804
TMPDIR=/var/folders/dz/wvb1lxq56wg_wk3ppwqw4mdc0000gn/T/
USER=me
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
__CFBundleIdentifier=com.googlecode.iterm2
__CF_USER_TEXT_ENCODING=0x0:0:0
me#my-iMac ~ %
I don't really like this behaviour. I can't find where that has been set to happen. I can't see anything in .zshenv, .zshrc, .bashrc and can't see where in iTerm such a thing might be triggered. I've tried creating a new profile, but that also results in the same output.
Any other suggestions to how I can get back to the way it was a few weeks back where it just told me the last time I logged in?
If you add set -x to ~/.zshenv, the shell will print every line it runs with file names and line numbers. You can then find the offending command and remove or fix it. My best guess would be a call to export without any arguments: something like export $foo, where $foo is empty?

Looping through the content of a file in Zsh

I'm trying to loop through the contents of a file in zsh. In my loop I want to get user input. Going off of this answer for Bash, I'm attempting to do:
while read -u 10 line; do
echo $line;
# TODO read from stdin here, etc.
done 10<myfile.txt
However I get an error:
zsh: parse error near `10'
Referring to the 10 after the done. Obviously I'm not getting the file descriptor syntax right, but I'm having trouble figuring out the docs.
Use a file descriptor number less than 10. If you want to hard code file descriptor numbers, stick to the range 3-9 (plus 0-2 for stdin,out,err). When zsh needs file descriptors itself, it uses them in the 10+ range.
If you're even getting close to needing more than the 7 available hard coded file descriptors, you should really think about using variables to name them. Syntax like exec {myfd}<myfile.txt will open a file with zsh allocating a file descriptor greater than 10 and assigning it to $myfd.
Bourne shell syntax is not entirely unambiguous given file descriptors numbering 10 and over and even in bash, I'd advise against using them. I'm not entirely sure how bash avoids conflicts if it needs to open any for internal use - I guess it never needs to leave any open. This may look like a zsh limitation at first sight but is actually a sensible feature.

Getting Started with SyntaxNet (start parsing text right away with Parsey McParseface)

I am new to SyntaxNet and I recently tried to install it step by step from https://github.com/tensorflow/models/blob/master/syntaxnet/README.md#instalation.
Although after running bazel test it was said that "Executed 12 out of 12 tests: 12 tests pass"
when I used this code
ubuntu#ubuntu-VirtualBox:~/Downloads/git-2.7.4/models/syntaxnet$
echo 'Bob brought the pizza to Alice.' |syntaxnet/demo.sh
it gives me this error:
syntaxnet/demo.sh: line 31: bazel-bin/syntaxnet/parser_eval:
No such file or directory
syntaxnet/demo.sh: line 43: bazel-bin/syntaxnet/parser_eval:
No such file or directory
syntaxnet/demo.sh: line 55: bazel-bin/syntaxnet/conll2tree:
No such file or directory
I would really appreciate if anyone could help me.
Thank you so much
I had the same issue.
To fix it, modify the demo.sh file, lines 31 and 55.
The locations it points to find parser_eval and conll2tree are wrong, at least they were in my system.
Do a search for "sudo find / -iname 'parser_eval'".
For me the location of this file was "/home/jesus/.cache/bazel/_bazel_jesus/afbbfe6033ddfb6168467a72894e5682/syntaxnet/bazel-out/local-opt/bin/syntaxnet/parser_eval"
I then proceeded to point line 31 to this location instead of "bazel-bin/syntaxnet/parser_eval".
Then did the same for line 55 and conll2tree.
Saved the file, and got it running.
Hope it helps
I had a similar problem, in case it might be useful to anyone. If you rename or move the path where syntaxnet is installed, you'll break half a dozen symbolic links it creates during installation (it uses absolute paths). In that case, you have to recreate the links with the new path.

Cannot compile. No space left on device error - Unix

I'm coding for class and when I try to compile I now get this error. Worked fine yesterday. IT does not work weekends so I'm out of luck until Monday unless someone can help. I'm fairly new to unix as I only really use it when coding.
cc scheduler.c
Close failure on scheduler.o : No space left on device
cc: acomp failed for scheduler.c
Delete some things on your disk. Use df (type 'man df' for usage) to see where the mount point is that you're compiling onto.
Check out the quota command. It'll show you how much space you get. You've probably just used up all the disk space you're allotted for you account. Go to your home directory:
> cd ~
and run:
> du -sh *
It will show how much space each of your directories takes up. Just remove some unused files.
If one directory takes up most of the space, you can cd into it and run du -sh * there too, to see the disk usage of its subdirectories. It's basically just a useful command for finding large files that you might not need anymore. For example, if you downloaded a really big program for a class project last year, but no longer need it, just rm it.

Compress EACH LINE of a file individually and independently of one another? (or preserve newlines)

I have a very large file (~10 GB) that can be compressed to < 1 GB using gzip. I'm interested in using sort FILE | uniq -c | sort to see how often a single line is repeated, however the 10 GB file is too large to sort and my computer runs out of memory.
Is there a way to compress the file while preserving newlines (or an entirely different method all together) that would reduce the file to a small enough size to sort, yet still leave the file in a condition that's sortable?
Or any other method of finding out / countin how many times each line is repetead inside a large file (a ~10 GB CSV-like file) ?
Thanks for any help!
Are you sure you're running out of the Memory (RAM?) with your sort?
My experience debugging sort problems leads me to believe that you have probably run out of diskspace for sort to create it temporary files. Also recall that diskspace used to sort is usually in /tmp or /var/tmp.
So check out your available disk space with :
df -g
(some systems don't support -g, try -m (megs) -k (kiloB) )
If you have an undersized /tmp partition, do you have another partition with 10-20GB free? If yes, then tell your sort to use that dir with
sort -T /alt/dir
Note that for sort version
sort (GNU coreutils) 5.97
The help says
-T, --temporary-directory=DIR use DIR for temporaries, not $TMPDIR or /tmp;
multiple options specify multiple directories
I'm not sure if this means can combine a bunch of -T=/dr1/ -T=/dr2 ... to get to your 10GB*sortFactor space or not. My experience was that it only used the last dir in the list, so try to use 1 dir that is big enough.
Also, note that you can go to the whatever dir you are using for sort, and you'll see the acctivity of the temporary files used for sorting.
I hope this helps.
As you appear to be a new user here on S.O., allow me to welcome you and remind you of four things we do:
. 1) Read the FAQs
. 2) Please accept the answer that best solves your problem, if any, by pressing the checkmark sign. This gives the respondent with the best answer 15 points of reputation. It is not subtracted (as some people seem to think) from your reputation points ;-)
. 3) When you see good Q&A, vote them up by using the gray triangles, as the credibility of the system is based on the reputation that users gain by sharing their knowledge.
. 4) As you receive help, try to give it too, answering questions in your area of expertise
There are some possible solutions:
1 - use any text processing language (perl, awk) to extract each line and save the line number and a hash for that line, and then compare the hashes
2 - Can / Want to remove the duplicate lines, leaving just one occurence per file? Could use a script (command) like:
awk '!x[$0]++' oldfile > newfile
3 - Why not split the files but with some criteria? Supposing all your lines begin with letters:
- break your original_file in 20 smaller files: grep "^a*$" original_file > a_file
- sort each small file: a_file, b_file, and so on
- verify the duplicates, count them, do whatever you want.

Resources