LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices


Old

BASH delete line from file

Posted 04-05-2020 at 05:12 PM by karanis
Tags bash

https://www.folkstalk.com/2013/03/se...-examples.html

sed '/^u/d' file
Deletes a line starting with u
LQ Newbie
Posted in Uncategorized
Views 187 Comments 0 karanis is offline
Old

BASH fork

Posted 04-05-2020 at 05:11 PM by karanis
Tags bash, fork

#!/usr/bin/bash
function_to_fork() {
...
}

function_to_fork &
# ... execution continues in parent process ...
LQ Newbie
Posted in Uncategorized
Views 212 Comments 0 karanis is offline
Old

nmap Scan Network (better&faster)

Posted 04-05-2020 at 05:10 PM by karanis
Tags bash, net

nmap -sL 192.168.*.* | grep \(1
ip neigh show dev eth1
LQ Newbie
Posted in Uncategorized
Views 261 Comments 0 karanis is offline
Old

Bash variables storing the output of commands run them at each variable statement, not just at some eventual invocation

Posted 08-10-2016 at 04:30 PM by the dsc (linux-related notes)
Updated 08-10-2016 at 04:33 PM by the dsc
Tags bash

Meaning that a script line such as:

nowstatus=`mpc | grep '#' | cut -d '/' -f1`

Is running mpc, grep and cut at its very statement, not only from an eventual "echo $nowstatus".

Therefore, in scripts that parse differently the same output of a given command, it may be preferable to first store this output in a temporary file, and then parse this file rather than running the same command several times. Such as in the lines added below their equivalent...
Member
Posted in Uncategorized
Views 1188 Comments 0 the dsc is offline
Old

N00b method to toggle some verbosity on command for bash scripts

Posted 03-28-2016 at 11:32 PM by the dsc (linux-related notes)
Updated 03-28-2016 at 11:34 PM by the dsc
Tags bash, newbie

Just something I came up with that is probably not how actual programmers/scripters(?) would advise, specially the parameter/flag thing which is beside the point here.

Code:
if [[ $1 == "v" ]] ; then

ver(){
echo $@
}

else

ver(){
:    # ":" is a "do nothing" command
}

fi

a=10

echo normal output

ver verbose output $a
...
Member
Posted in Uncategorized
Views 1318 Comments 0 the dsc is offline

  



All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration