development

Find a String in Files Excluding Some Files

— tags: ‘shell, linux, command, development, grep,find’ categories: development — I use the following command to find a string in a Go repo. The vendor directory is not needed, so skip it. $ find . -type f |grep -v vendor|cut -d”:” -f2|xargs grep -n my_search_string The command find all files in current directory. Next, it […]

Read more
development

Fixing Terminal Row & Columns Display on Docker and Linux

Ever faced garbled screen on a terminal, text wrapping over and screen command string messed up! It happens because the terminal is using default row and column value (e.g. columns = 80). The following command fixes it (tested on Docker container’s terminal) docker exec -e COLUMNS=”`tput cols`” -e LINES=”`tput lines`” -ti How it Works? tput […]

Read more
development

xargs: ls: terminated by signal 13

The following command hits a problem with sig 13. $ find . -type f|xargs ls -altr|head -rw-r–r– 1 root root 254111 Mar 17 2018 ./60/62 -rw-r–r– 1 root root 135111 Mar 17 2018 ./60/66 xargs: ls: terminated by signal 13 Why did it fail? $ strace find . -type f|xargs ls -altr|head newfstatat(AT_FDCWD, “xyxyx”, {st_mode=S_IFREG|0644, […]

Read more
development, linux, Linux internals

Linux FUSE Internals for developers

In this post, I will cover FUSE internals for FUSE 2.9.3. Install package fuse and fuse-devel on CentOS. getattr() is a must in a FUSE file-system. Any lame implementation is okay; Just be careful of the file size in stat structure. If you forgot to compile user file system with 64-bit flags on. Otherwise the […]

Read more
development

Forward declaration of a structure in C

What do you think of following code? /* * decl.h */ struct junk { int a; }; ———————————————- /* * fwd.c * We have not included the header file decl.h. */ #include struct junk; int main() { struct junk *ptr; printf(“%d”, ptr->a); } You will get compilation error that structure object ptr is incomplete. This […]

Read more