Most Popular

1500 questions
107
votes
10 answers

How to grep for same string but multiple files at the same time?

I have a set of log files that I need to review and I would like to search specific strings on the same files at once Is this possible? Currently I am using grep -E 'fatal|error|critical|failure|warning|' /path_to_file How do I use this and search…
user53029
  • 2,725
  • 8
  • 40
  • 65
107
votes
3 answers

How to grep the output of cURL?

I need to retrieve the expiry date of an SSL cert. The curl application does provide this information: $ curl -v https://google.com/ * Hostname was NOT found in DNS cache * Trying 212.179.180.121... * Connected to google.com (212.179.180.121) port…
dotancohen
  • 15,494
  • 26
  • 80
  • 116
107
votes
7 answers

Is Mac OS X UNIX?

I had this argument recently saying Mac OS X was not UNIX, but Unix-like. I know there is a Single Unix Specification and those spec compliant could use the UNIX trade mark. Is Mac OS X a UNIX operating system or is it a Unix-like?
OscarRyz
  • 1,265
  • 3
  • 10
  • 8
107
votes
2 answers

What is this new /run filesystem?

I just ran df -h a minute ago and noticed a filesystem has been added that I'm not familiar with. Does anyone know why /run exists? Is this something that's been added by the kernel? By Arch Linux? run 10M 236K 9.8M 3% /run
xenoterracide
  • 57,918
  • 74
  • 184
  • 250
107
votes
11 answers

Remember a half-typed command while I check something

I often find myself in the following position: I've started typing a long command at the bash prompt, but half-way through I find out I need to check something with another command. This is a problem when I'm at the console (no X), which is often…
Lauritz V. Thaulow
  • 3,469
  • 4
  • 23
  • 22
106
votes
3 answers

What is stored in /dev/pts files and can we open them?

According to my knowledge, /dev/pts files are created for ssh or telnet sessions.
user2720323
  • 3,549
  • 7
  • 24
  • 26
106
votes
10 answers

shell command to get pixel size of an image

Is there a shell command that returns the pixel size of an image? I'm trying to produce an animated gif starting from different gifs with different sizes using convert (e.g. convert -delay 50 1.gif 2.gif -loop 0 animated.gif). The problem is that…
blue
  • 2,812
  • 4
  • 17
  • 14
106
votes
7 answers

Shell script fails: Syntax error: "(" unexpected

I've been working on a script that automates setting up a development environment for Raspberry Pi development (step by step details that work are here). The script is linked in that article but convenience you can find it here also. Now when run…
kemra102
  • 1,061
  • 2
  • 11
  • 16
106
votes
9 answers

Bash: Assign output of pipe to a variable

I am trying to get the output of a pipe into a variable. I tried the following things: echo foo | myvar=$(
Parckwart
  • 1,061
  • 2
  • 8
  • 5
106
votes
8 answers

#!/bin/bash - no such file or directory

I've created a bash script but when I try to execute it, I get #!/bin/bash no such file or directory I need to run the command: bash script.sh for it to work. How can I fix this?
Nicolas de Fontenay
  • 4,209
  • 8
  • 21
  • 18
106
votes
5 answers

How do I remove the newline from the last line in a file in order to add text to that line?

Suppose I have a file called file: $ cat file Hello Welcome to Unix I want to add and Linux at the end of the last line of the file. If I do echo " and Linux" >> file will be added to a new line. But I want last line as Unix and Linux So, in order…
Pandya
  • 23,898
  • 29
  • 92
  • 144
106
votes
5 answers

Using awk to sum the values of a column, based on the values of another column

I am trying to sum certain numbers in a column using awk. I would like to sum just column 3 of the "smiths" to get a total of 212. I can sum the whole column using awk but not just the "smiths". I have: awk 'BEGIN {FS = "|"} ; {sum+=$3} END {print…
jake
  • 1,205
  • 2
  • 10
  • 9
106
votes
3 answers

How to make tree output only directories?

150 directories I can handle but 900 files is too many for a review. I've no manual entry for tree so maybe I can ask you if you know how to output only directories since files get too detailed? . ├── agreement.htm ├── appengine_admin │   ├──…
Niklas Rosencrantz
  • 4,112
  • 6
  • 36
  • 58
106
votes
7 answers

How to use command line to change volume?

I am trying to control the volume using my programming script. How can I do the following in Fedora 15, Ubuntu linux? Mute/ Unmute Volume up and volume down Note: Please note that I use a web USB microphone/speaker and also Analogue…
user11085
106
votes
2 answers

how to count the length of an array defined in bash?

I'm new to bash and can't find a good tutorial to answer my question. array=( item1 item2 item3 ) for name in ${array[@]}; do echo current/total ... some other codes done I want to calculate the current and total value, as the expected…
AGamePlayer
  • 7,415
  • 16
  • 46
  • 55