Run a built-in shell function in a script read with chat

#!/usr/bin/env bash function foo(){ param=$1 echo "$param" } content="calling this one with param: $(foo 'this is test param1')" echo "$content" result: calling this one with param: this is test param1 Notice that foo is call

grep, how to search for an exact pattern?

This was what I have tried grep -n 'qtrain' *.m But I got also SKSC.m:195:model.qtrain = model.qtrainExtra(:,k-1); SKSC.m:196:model.mqtrain = model.mqtrainExtra{k-1}; SKSC.m:197:model.sqtrain = model.sqtrainExtra{k-1}; How to get rid of the others? I

Script to download a web page

i made a web server to show my page locally, because is located in a place with a poor connection so what i want to do is download the page content and replace the old one, so i made this script running in background but i am not very sure if this wi

Bash - Exclude subdirectories with the find command

This question already has an answer here: How to exclude a directory in find . command 29 answers I'm using the find command to get a list of folders where certain files are located. But because of a permission denied error for certain subdirectories

bash script to perform dig -x

Good day. I was reading another post regarding resolving hostnames to IPs and only using the first IP in the list. I want to do the opposite and used the following script: #!/bin/bash IPLIST="/Users/mymac/Desktop/list2.txt" for IP in 'cat $IPLIS

How to leave a bash function waiting for a return

I'm not completely clear on the how/why bash's exit keyword is inconsistant when calling a function that expects a return vs. not expecting a return. For instance, in the following repro: #!/bin/bash exitfunc() { echo "Flag 1" exit } exitfunc ec

check a specific delimiter per line - bash

I want to write a script in bash that handles a file with lines that has 5 columns and i expect the delimiters to be one single space (" "). everything other than that should lead to an error, even more than 1 space. for instance, that line is l

Analyze the JSON array: 'paste' for bash variables?

At first, I parsed an array JSON file with a loop using jshon, but it takes too long. To speed things up, I thought I could return every value of id from every index, repeat with word another type, put these into variables, and finally join them toge

Where to put shell script / function? .bashrc or bin?

I am learning Linux commands and I learnt that you can write a shell script and put in a customized directory (e.g. ~/bin/ ) and export to $PATH or you can write it as a shell function and put in .bashrc file. If I may ask, what is the right situatio

Make 2 ajax request for a bash treatment

I'm making an ajax request which is making bash treatment. Another action in my page uses an ajax request but this one is waiting the end of my first request for making what I'm asking. Do you have any idea for doesn't waiting the end of the first aj

Bash: read lines in a file in a table

This question already has an answer here: Creating an array from a text file in Bash 6 answers I am trying to read a file containing lines into a Bash array. I have tried the following so far: Attempt1 a=( $( cat /path/to/filename ) ) Attempt2 index=

Why does wget give me two different download times?

The last 3 lines of wget -i urls.txt: FINISHED --2012-05-16 12:58:08-- Total wall clock time: 1h 56m 52s Downloaded: 1069 files, 746M in 1h 52m 49s (113 KB/s) There are two different times: 1h 56m 52s 1h 52m 49s Why are they different? What do they s

short date in bash prompt PS1

You can use \d in the your PS1 confuration to display a long date ie. Tues 18 May, but how can I get it to display it in a format like 18.05.2012 for example?Try this: PS1="\$(date +%d.%m.%Y) > " export PS1

How can I escape spaces in $ HOME in a bash script?

I'm trying to run a script which uses my $HOME variable to set things up (it's gitolite, by the way). However, it's failing because I'm on a system where the home directory path has spaces in it. I want to hack the gitolite bash script at a single po

bash script to run in 5 minutes

I just want a bash script to run 5 minutes after it's called. What am I doing wrong? I have the command: /path/to/my/script | at now + 5 min And yet the script runs right away every time.You are executing the script immediately and sending its output

How to create a bash script to check the SSH connection?

I am in the process of creating a bash script that would log into the remote machines and create private and public keys. My problem is that the remote machines are not very reliable, and they are not always up. I need a bash script that would check

Makefile for the program running on different machines

I have a C++ program that will run on several machines that use a Network File System. For each of the C++ libraries that my program uses, I installed a version for each machine, under ~/program_files/machinename/libraryname. "machinename" is ob