LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices


Old

converting all Lower chareacters to Upper and vice versa using sed

Posted 03-27-2014 at 05:30 AM by dinakumar12

sed -i 's/\(.*\)/\U\1/' samplefile #This converts the contents of samplefile (filename) from Lower to upper


sed -i 's/\(.*\)/\L\1/' samplefile #This converts the contents of samplefile (filename) from Upper to Lower
Member
Posted in Uncategorized
Views 656 Comments 0 dinakumar12 is offline
Old

Simple script to delete last n lines

Posted 10-29-2013 at 10:53 AM by dinakumar12
Updated 12-31-2013 at 01:18 AM by dinakumar12

This may be possible using a single command but a very small and simple script though.Here we are deleting last 3 lines from a file.

#!/bin/bash
#Assign the number of lines to be deleted to variable "a"
a=3
i=1
while [ $i -le $a ]
do
sed -i '$d' file
i=$(($i + 1))
done
Member
Posted in Uncategorized
Views 6225 Comments 2 dinakumar12 is offline
Old

simple script for creating 100 users in linux

Posted 01-17-2012 at 07:35 AM by dinakumar12
Updated 01-20-2012 at 02:36 AM by dinakumar12

#!/bin/bash
a=1
while [ $a -le 101 ]
do
{
useradd user$a
a=`expr $a + 1`
}
done
Member
Posted in Uncategorized
Views 842 Comments 0 dinakumar12 is offline
Old

one time changing of default user's home directory while adding newuser

Posted 01-17-2012 at 05:28 AM by dinakumar12

vim /etc/default/useradd

Look for this line

HOME=/home

change /home to your own directory

save the file and try adding new user by useradd username

Now the new user should be created with your own preferred directory.
Member
Posted in Uncategorized
Views 522 Comments 0 dinakumar12 is offline
Old

How to insert a string at the top of a file using sed

Posted 01-17-2012 at 05:22 AM by dinakumar12
Updated 01-18-2012 at 09:42 AM by dinakumar12

sed -i 1i\string filename
Member
Posted in Uncategorized
Views 660 Comments 0 dinakumar12 is offline

  



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