Skip to main content
Filter by
Sorted by
Tagged with
7706 votes
57 answers
12.1m views

How do I find all files containing a specific string of text within their file contents? The following doesn't work. It seems to display every single file in the system. find / -type f -exec grep -H '...
Nathan's user avatar
  • 79.4k
2846 votes
34 answers
2.1m views

I am trying to print a text in a red color in the terminal using echo command. How can I do that?
satheesh.droid's user avatar
2322 votes
51 answers
2.0m views

How do I exclude a specific directory when searching for *.js files using find? find . -name '*.js'
helion3's user avatar
  • 38k
2249 votes
27 answers
2.5m views

How do I recursively grep all directories and subdirectories? find . | xargs grep "texthere" *
wpiri's user avatar
  • 22.6k
2182 votes
20 answers
756k views

How do I find areas of my code that run slowly in a C++ application running on Linux?
Gabriel Isenberg's user avatar
1920 votes
40 answers
1.4m views

I want to pause input in a shell script, and prompt the user for choices. The standard Yes, No, or Cancel type question. How do I accomplish this in a typical bash prompt?
Myrddin Emrys's user avatar
1677 votes
12 answers
1.2m views

In bash, calling foo would display any output from that command on the stdout. Calling foo > output would redirect any output from that command to the file specified (in this case 'output'). Is ...
SCdF's user avatar
  • 59.7k
1537 votes
3 answers
1.2m views

How can I use grep to show just file-names (no in-line matches) on Linux? I am usually using something like: find . -iname "*php" -exec grep -H myString {} \; How can I just get the file-...
cwd's user avatar
  • 55.2k
1522 votes
3 answers
3.1m views

I want to recursively create a copy of a directory and all its contents (e.g. files and subdirectories).
user2080656's user avatar
  • 15.3k
1457 votes
28 answers
1.9m views

I have a text file, and I like to know the total number of line withou opening it. My document is like these, and I want to know how many lines actually... 09:16:39 AM all 2.00 0.00 4.00 ...
Alucard's user avatar
  • 17.5k
1273 votes
16 answers
548k views

What is export for? What is the difference between: export name=value and name=value
flybywire's user avatar
  • 276k
1212 votes
10 answers
1.1m views

I have a symlink to an important directory. I want to get rid of that symlink, while keeping the directory behind it. I tried rm and get back rm: cannot remove 'foo'. I tried rmdir and got back rmdir: ...
Matthew Scouten's user avatar
1190 votes
12 answers
802k views

I'm studying the content of this preinst file that the script executes before that package is unpacked from its Debian archive (.deb) file. The script has the following code: #!/bin/bash set -e # ...
AndreaNobili's user avatar
  • 43.3k
1146 votes
31 answers
1.4m views

Is there a simple shell command/script that supports excluding certain files/folders from being archived? I have a directory that need to be archived with a sub directory that has a number of very ...
deepwell's user avatar
  • 21.1k
1140 votes
34 answers
1.5m views

I've noticed with docker that I need to understand what's happening inside a container or what files exist in there. One example is downloading images from the docker index - you don't have a clue ...
user2668128's user avatar
1112 votes
5 answers
138k views

Why does the C preprocessor in GCC interpret the word linux (small letters) as the constant 1? test.c: #include <stdio.h> int main(void) { int linux = 5; return 0; } Result of $ ...
ahmedaly50's user avatar
  • 7,855
1102 votes
36 answers
1.9m views

Is there an easy way I can print the full path of file.txt ? file.txt = /nfs/an/disks/jj/home/dir/file.txt The <command> dir> <command> file.txt should print /nfs/an/disks/jj/home/...
Jean's user avatar
  • 23k
1080 votes
13 answers
1.8m views

I needed to write a script to enter multi-line input to a program (psql). After a bit of googling, I found the following syntax works: cat << EOF | psql ---params BEGIN; `pg_dump ----...
hasen's user avatar
  • 167k
981 votes
19 answers
1.5m views

What is the best way to open a file as read/write if it exists, or if it does not, then create it and open it as read/write? From what I read, file = open('myfile.dat', 'rw') should do this, right? It ...
trh178's user avatar
  • 11.7k
955 votes
9 answers
1.5m views

I know that in Linux, to redirect output from the screen to a file, I can either use the > or tee. However, I'm not sure why part of the output is still output to the screen and not written to the ...
Rayne's user avatar
  • 15.2k
934 votes
7 answers
899k views

I need something simple like date, but in seconds since 1970 instead of the current date, hours, minutes, and seconds. date doesn't seem to offer that option. Is there an easy way?
n-alexander's user avatar
  • 15.5k
924 votes
19 answers
1.8m views

I'm trying to use the cp command and force an overwrite. I have tried cp -rf /foo/* /bar, but I am still prompted to confirm each overwrite.
Thiyagarajan Varadharaj's user avatar
906 votes
15 answers
476k views

The Imagemagick security policy seems to be not allowing me perform this conversion from pdf to png. Converting other extensions seem to be working, just not from pdf. I haven't changed any of the ...
T. Zack Crawford's user avatar
896 votes
18 answers
2.0m views

I know the POSIX sleep(x) function makes the program sleep for x seconds. Is there a function to make the program sleep for x milliseconds in C++?
Prasanth Madhavan's user avatar
890 votes
13 answers
454k views

Is that possible to use grep on a continuous stream? What I mean is sort of a tail -f <file> command, but with grep on the output in order to keep only the lines that interest me. I've tried ...
Matthieu Napoli's user avatar

1
2 3 4 5
4552