Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 2770  / 2 Years ago, fri, december 24, 2021, 11:49:25

I have a file and I need to delete its first letter of each lines. I tried this:



for i in
do
if [ $5 -eq cat harfler | grep `head -n i harfler | head -c 1` ]
then
echo "succeded"
tr -d `head -n i`
fi
done


but nothing happens. Doesn't even echo "succeeded". Any idea why?


More From » bash

 Answers
7

Use sed as following:



sed 's/^.//' file


For line if starts with spaces:



sed 's/S//' file


Matches any non-white space character but not newline. You can use w or [A-Za-z0-9_] instead.



The command suggested by @gleenjackman:



sed 's/[^[:blank:]]//' file


or



sed 's/[^[:space:]]//' file


or



sed 's/[[:alpha:]]//' file


or contains numbers:



sed 's/[[:alnum:]]//' file


or use:



while read line; do echo "${line:1}" ;done < file

[#21811] Saturday, December 25, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
azaaburge

Total Points: 266
Total Questions: 85
Total Answers: 109

Location: Djibouti
Member since Sat, Oct 29, 2022
2 Years ago
azaaburge questions
Thu, Jun 2, 22, 23:28, 2 Years ago
Sun, Oct 17, 21, 05:20, 3 Years ago
Fri, Jun 25, 21, 16:22, 3 Years ago
;