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

Notices


Old

BASH read file

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

https://www.cyberciti.biz/faq/unix-h...ine-from-file/

https://www.computerhope.com/unix/bash/read.htm

https://www.shellhacks.com/bash-read...ead-line-loop/

----------

while read USER; do echo "Hello $USER!"; done < users.txt

----------

#!/bin/ksh
file="/home/vivek/data.txt"
while IFS= read line
do
# display $line...
LQ Newbie
Posted in Uncategorized
Views 314 Comments 0 karanis is offline
Old

BASH datetime for scripts

Posted 04-05-2020 at 05:16 PM by karanis
Tags bash, time

#!/bin/bash
dt=`date '+%d/%m/%Y %H:%M:%S'`
echo "$dt"
LQ Newbie
Posted in Uncategorized
Views 299 Comments 0 karanis is offline
Old

BASH get ip from ifconfig ( and grep hostname from /etc/hosts by IP)

Posted 04-05-2020 at 05:13 PM by karanis
Updated 04-05-2020 at 05:15 PM by karanis
Tags bash, net

#!/bin/bash

IP=`/usr/sbin/ip addr show dev eth0| grep -v inet6| awk ' !/127.0.0.1/ && /inet/ { gsub(/\/.*/, "", $2); print $2 }'`
grep $IP /etc/hosts | sed -r s/$IP\\s\\t//
LQ Newbie
Posted in Uncategorized
Views 806 Comments 0 karanis is offline
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 188 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 213 Comments 0 karanis is offline

  



All times are GMT -5. The time now is 08:41 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