I have below file. I want to remove space at begining of every line and then after also remove blank line from file.
I use below code for each operation.
sed -e 's/^[ \t]//' < check.txt > check1.txt
sed '/^\s$/d' < check1.txt > check2.txt
above code not remove all the space and blank line. any one can help in this.
cat check.txt
CREATE TABLE $SC.TMP_TBL --- first step (
ALTER TABLE $SC.TMP_TBL LOCKSIZE TABLE APPEND ON
ERROR: While creating temp table TMP_TBL!
ERROR: While loading records into table Z_KD!
Loading of table Z_KD is successfull!
CREATE TABLE $SC.TMP_TBL AS
ALTER TABLE $SC.TMP_TBL LOCKSIZE TABLE APPEND ON
ERROR: While creating temp table TMP_TBL!
ule3-Trial 3 to update RECHTSFORM
MERGE INTO $SC.Z_KD a USING (
ERROR: While loading records into table Z_KD(Rule3-Trial3)!
CREATE TABLE $SC.TMP_TBL
ALTER TABLE $SC.TMP_TBL
awk 'NF {$1=$1;print}' check.txt
CREATE TABLE $SC.TMP_TBL --- first step (
ALTER TABLE $SC.TMP_TBL LOCKSIZE TABLE APPEND ON
ERROR: While creating temp table TMP_TBL!
ERROR: While loading records into table Z_KD!
Loading of table Z_KD is successfull!
CREATE TABLE $SC.TMP_TBL AS
ALTER TABLE $SC.TMP_TBL LOCKSIZE TABLE APPEND ON
ERROR: While creating temp table TMP_TBL!
ule3-Trial 3 to update RECHTSFORM
MERGE INTO $SC.Z_KD a USING (
ERROR: While loading records into table Z_KD(Rule3-Trial3)!
CREATE TABLE $SC.TMP_TBL
ALTER TABLE $SC.TMP_TBL
@Mohin Jain
Why did you delete the input in post#1. Its difficult to help without any date. $1=$1 in awk also removes tabs, not only spaces.
So code should work.
I agree, but The standard white-space characters are the following:
` ' Space character.
\f Form feed.
\n New-line.
\r Carriage return.
\t Horizontal tab.
\v Vertical tab.
And these are covered by [:space:].
Regards.