How to force `ls` to 64-bit sizes? - 64-bit

ls will, as far as I can tell, only write out file sizes as 32-bit ints. This has caused problems for me when I have a 5.4GB files that it insists are only 1.6GB. I'm on GNU coreutils version 5.97 and it's becoming a problem. Is there a compilation flag or otherwise command-line option to fix this?

5.97 is 10 years old now, but it should have been using AC_SYS_LARGEFILE back then. What system is this?

Related

Gitbash version does not allow grep -o, is it possible to install new grep package?

I am trying to do a directory-wide search for specific strings in JSON files. The only problem is that these JSON files are only one line, so when I cat all of them, all strings occur a magical "1" time...since there's only one line even when I string them all together.
An easy solution, which I see a lot (here and here), is grep -o. Only problem is it doesn't come standard on my Gitbash. I solved my immediate problem by just installing the latest Cygwin. However, I'm wondering if there was an easier/more granular solution. Is it possible to do the equivalent of "apt-get install" or similar on Gitbash? Or can someone explain to me a quick-and-dirty way to extract and install the tar file in Gitbash?
The other approach is to:
use a cmd session (using the git-cmd.bat which packaged with Git for Windows)
use the grep included Gnu for Windows, which supports the -o option (and actually allow you to use most of the other Unix commands that your script might be currently using)

how to find path from where current binary running?

After somewhere searching finally not getting what i want.
I am working on some embedded board with linux system. And many users access it by telnet.So each user suppose copy some binary somewhere and executed like ./binary.So i can see this process running by simply ps command but from where it's running i don't know.
somewhere found that, use which command but as per my understanding(if i am not wrong) which command find only path of that binary whether it's currently executing or not.
And what if multiple users copied same binary in different path?
Also looked another solution use readlink but limited busybox binary supported in my target board. So readlink is not there.
One another solution like
file /proc/"proess id"/exe but here file command not present because of custome linux in my board which contain only limited functionality and binary.
So any other solution is there?
Try ls -l /proc/"proess id"/exe. ls utility from GNU coreutils shows links with -l option, but I don't have exact information about ls from busybox.

Preview man-page without installing package

I've checked out some typical open source project which is using auto-tools. I want to hack a bit on this package, but I would also like to change something in the man-page of the package.
The man-page source is found project-name/doc/project-name.1. I just made a small change, and now I want to preview that change, without having to actually do a make install of the project. How do I do that?
I tried stuff like:
man -M . 1 project-name
But it does not work, neither does the various variations I have tried. This sounds like a simple problem, but I can't seem to find anything by googling on the problem, so I'm hoping someone here can help me out. Thanks.
man -l /path/to/manfile.1
On my system, the output from this command is different from nroff -man file.1 | less. Paragraphs wrap at the edge of the terminal, for instance, rather than at 78 characters.
nroff -man /path/to/manfile.1 | less

cygwin slow file open

My application uses fopen to open a lot of files. While in linux opening and reading thousand of files doesn't even take a second; in cygwin it takes more than 5 seconds.
I think it is because path conversion functions in cygwin dlls. 'open' function is a bit faster. If I use -mno-cygwin it becomes very fast but I can't use it.
Is there an easy way to make cygwin dlls just open files; without any linux-windows conversion?
It depends on how the system was mounted in the Cygwin environment.
$ mount
C:/cygwin/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
D: on /cygdrive/d type iso9660 (binary,posix=0,user,noumount,auto)
The mount option "binary" makes it so CRLF <-> LF conversions are not performed on files read from the volume. This is default.
Some things you can do to speed up a Cygwin prompt are the following:
Add the following lines to your ~/.bashrc:
# eliminate long Windows pathnames from the PATH
export PATH='/bin:/usr/bin:/usr/local/bin'
# check the hash before searching the PATH directories
shopt -s checkhash
# do not search the path when .-sourcing a file
shopt -u sourcepath
Disconnect your network drives.
Disable your antivirus, or otherwise exclude Cygwin's folders from its scans.
Thorough antivirus programs scan files for malware as they're opened by programs, and this means it'll be working overtime if your script is opening thousands of files.
Use the option --cache-file="$HOME/.config.cache" when running autotools configure scripts.
This will create a file that holds prerecorded configure discoveries, most of which are usable between software builds. (This is also a good idea when using Linux).
Since the shell seems to be the bottleneck of the Cygwin system, a huge script that relies on starting a large number of processes will take forever and this will cut down on the number of processes it needs to start.
Set up Cygwin's sshd and stop using Windows Command Prompt in favor of PuTTY.
PuTTY responds better to changing text on the screen, as it was built for the more mature CLI interface of *NIX.

Defaulting cygwin to use CRLF

I'm using a windows PC and editing files checked out from SVN, which has files checked in using DOS.
I use cygwin and when I either create a new file or patch a file using cygwin binaries the file format is unix. Really I need to always use DOS format for these so my colleagues are not inconvenienced.
Is there any way I can have cygwin use DOS format for say a bash session?
I appreciate I can run unix2dos against such files but this is a pain - I'd rather just have them as DOS to begin with if possible.
You can make SVN do this conversion for you automatically. Check out propset and the eol-style option:
http://svnbook.red-bean.com/en/1.1/ch07s02.html#svn-ch-7-sect-2.3.5
This will make the files always have the newline sequence native to the platform on which you checked out the files (i.e., you may get them in LF and the other ones will have the same files with CRLF):
svn propset svn:eol-style native put-your-filenames-here
You can choose the UNIX or DOS file format during the installation of cygwin.

Resources