All Questions
19 questions
1
vote
1
answer
629
views
bash script to redirect the output of 'cut' / 'find' to 'scp' with some transformations applied
I need to redirect the output of cut / find to scp with filename transformations applied in between.
Background:
I am using clearcase for version control. I have branch feature brached off of /Main. ...
1
vote
1
answer
2k
views
Piping errors to my function causes command to be ignored after 1 failure
Context: I have a Bash Script that copies files
function log () {
read IN
if [ "$IN" == "" ]; then
:
else
echo "$datetime"$'\t'"$IN" | tee -a logfile
fi
}
function ...
15
votes
3
answers
2k
views
head eats extra characters
The following shell command was expected to print only odd lines of the input stream:
echo -e "aaa\nbbb\nccc\nddd\n" | (while true; do head -n 1; head -n 1 >/dev/null; done)
But instead it just ...
0
votes
1
answer
886
views
Removing lines and trailing commas from mysqldump
I'm trying to remove constraints from a mysqldump before piping it into another SQL database. Mysqldump generates tables that look something like this with 1 or more constraints:
CREATE TABLE `...
5
votes
2
answers
2k
views
A better way than `tee | cut | ... | paste`
Trying to do a "lookup" in a pipeline, where the input looks like this:
alice 5
bob 7
...
I want to look up codes in the second column in a database and return the corresponding name, and keep on ...
1
vote
1
answer
156
views
Why don't the SHA's match?
I am trying to write a script and it uses the SHA of a date but I am getting two different results and for the life of me can't figure out why.
echo -n 03112016 | cut -d'.' -f4 | sha256sum | cut -d' '...
0
votes
1
answer
917
views
Trying to Use awk by implementating a condition and implication
I have a file containing 8 columns, One of my tasks is to get the values of Column 3 and if the value of the row is not equal to 123 the 8 coloumns will be printed and hence If column 3 is equal to ...
3
votes
2
answers
5k
views
Curl url txt file, but grep each url separately from single file
I have a text file with lots of url's in it. I'm using
curl -K "$urls" > $output
to spit the output to my output file. Now for the output of each separate url there is a term, let's say "mortgage",...
1
vote
4
answers
2k
views
optimize command with or and pipe to parse the output of ifconfig
I have this command line, but it's doubling the grep and awk
ifconfig eth1 2> /dev/null | grep "inet " | awk '{gsub("addr:","",$2); print $2 }' ||
ifconfig eth0 2> /dev/null | grep "inet " | ...
2
votes
2
answers
2k
views
One-liner to sort and uniq two outputs
I'm currently doing this to sort and uniq the output of two different commands:
tshark -r sample.pcap -T fields -e eth.src -e ip.src > hello
tshark -r sample.pcap -T fields -e eth.dst -e ip.dst &...
2
votes
3
answers
4k
views
Extract two values from the output of a command
I'm using the following command in a script to get synthetic wifi info:
echo "$(
iw dev wlp1s0 link |
grep '^\s*SSID:\s' |
sed -r 's/^\s*SSID:\s//'
) $(
iw dev wlp1s0 link |
grep '...
3
votes
1
answer
1k
views
Command for killing specific PID provided by previous command
Sometimes I need to kill a process (the reasons why are not important). And I know I can find that process with the following command: lsof -i :8080, being my candidate the last process in the output ...
14
votes
9
answers
5k
views
Filter or pipe certain sections of a file
I have an input file with some sections the are demarcated with start and end tags, for example:
line A
line B
@@inline-code-start
line X
line Y
line Z
@@inline-code-end
line C
line D
I want to apply ...
5
votes
4
answers
3k
views
How to fill a file with a stream from /dev/urandom with a specified number of lines ?
I am trying to fill a file with a sequence of random 0 and 1s with a user-defined number of lines and number of characters per line.
the first step is to get a random stream of 0 and 1s:
cat /dev/...
10
votes
4
answers
3k
views
Split an input for different command and combine the result
I know how to combine the result of different command
paste -t',' <(commanda) <(commandb)
I know pipe same input to different command
cat myfile | tee >(commanda) >(commandb)
Now how to ...