Removing all blank lines, leading and trailing blank spaces :
#sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' prabhat.txt > kumar.txt
This command will create new file (kumar.txt) on which it removes blank lines, leading and trailing blank spaces.
Showing posts with label script. Show all posts
Showing posts with label script. Show all posts
Saturday, April 12, 2008
Wednesday, March 19, 2008
Remove all empty directories
$ cleanlinks
this is supported on few flavor of Linux (XFree86), you can use this script.
#/bin/bash
DIR="$1"
[ -d $DIR ] && [ $(ls -l $DIR | wc -l) -eq 1 ] && rmdir $DIR || :
$ script.sh dir1
this is supported on few flavor of Linux (XFree86), you can use this script.
#/bin/bash
DIR="$1"
[ -d $DIR ] && [ $(ls -l $DIR | wc -l) -eq 1 ] && rmdir $DIR || :
$ script.sh dir1
Removing blank line from file
Using sed.
$ sed '/^$/d' withblankline.txt > withoutblankline.txt
Using grep.
$ grep -v '^$' withblankline.txt > withoutblankline.txt
Use following for loop (shell script) to remove all blank lines from all files stored in /home/prabhat/data directory:
$ sed '/^$/d' withblankline.txt > withoutblankline.txt
Using grep.
$ grep -v '^$' withblankline.txt > withoutblankline.txt
Use following for loop (shell script) to remove all blank lines from all files stored in /home/prabhat/data directory:
#!/bin/sh
files="/home/prabhat/data/*.txt"
for f in $files
do
sed '/^$/d' $i > $i.out
mv $i.out $i
done
Subscribe to:
Posts (Atom)
Basics of Kubernetes
Kubernetes, often abbreviated as K8s , is an open-source platform designed to automate the deployment, scaling, and management of container...
-
The Unix top command is designed to help users determine which processes are running and which applications are using more memory or process...
-
Rotating MySQL Log Files on Linux. A. Check logrotate must on daily cron #less /etc/cron.daily/logrotate B. Check on logrotate.d there must ...
-
Security Issues with MySQL ROOT Access MySQL offers simple but very effective security mechanisms. Unfortunately, the default installation o...