To me it seems you do not remove all before first space to arrive at this output from your input but in fact remove everything up to and including the last space, no? In fact, looking at what the proposed output from the input should be in other lines you want to get the last (rightmost) group of adjoining non-space characters in every line. Is that so?
Moderator's Comments:
Furthermore: we have special rules in place in this homework forum. If you posted here erronously contact a moderator to have this thread moved to the normal forum parts. If this is indeed homework you need to fill out the questionnaire, otherwise you will get no answers and the thread will be closed.
this is not my homework....its is just i need to learn few skills in unix.....i posted in in homework beacuse i dont get link to post in main forum......as i m new it will take some time for me to understand the functionality of this forum...so m sorry for trouble
The problem is that the English description of the desired output and the sample desired output shown in the 1st post in this thread do not match
The code suggested by Corona688 produces the sample output from the sample input (without caring about what appears before the first space.
The code MadeInGermany suggested removes any characters that appear before the 1st character in the space character class AND the 1st character in the space character class (which does not match the English description of the problem and does not produce the sample output).
The English description of the problem is incomplete. It doesn't say what should happen to an input line that does not contain a space. It could be interpreted to mean that if there is no space, no change is to be made (as is shown in the sample output for some sample input lines), or it could be interpreted to mean that all characters should be removed from lines that do not contain a space character. (And note that the description talks about "a space"; not a character in the space character class.)
The following script shows one way to meet the stated English requirements for either interpretation:
and produces the output:
which, of course, is nothing at all like the sample output provided!
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/^*//' < check.txt > check1.txt
sed '/^\s*$/d' < check1.txt > check2.txt
above code not remove all the space... (12 Replies)
I created a awk state to calculate the number of success however when the query runs it has a leading zero. Any ideas on how to remove the leading zero from the calculation?
Here is my query:
cat myfile.log | grep | awk '{print $2,$3,$7,$11,$15,$19,$23,$27,$31,$35($19/$15*100)}'
02:00:00... (1 Reply)
Hi
I am trying to remove trailing space from a string.
value=${value%% }
It is not working. What might be the issue with the above snippet. (7 Replies)
Hi Guys,
I want remove starting space of each line ...
My Input:
A B C D E
C V F G H
F R T Y U
D F G H J
L O I U Y G P O
K O P L O
L O I P
P O P
P P P P
My Output:
A B C D E
C V F G H (7 Replies)
I have a script that shows me the disk SPace used by different dir under my home dir:
#!/bin/ksh
cd /ednpdtu3/u01/pipe
p1=`df -g | tail -1 | tr -s " " | cut -d " " -f2`
echo "Total Disk Space of Home Dir is $p1 GB"
p2=`df -g | tail -1 | tr -s " " | cut -d " " -f3`
echo "Total Disk Space... (2 Replies)