Results 1 to 4 of 4
Hi All,
Could you please help me out here!
Issues:
I have the file name like A4LNEU__20061123. I would like like the split the name of the file to 2 ...
- 05-30-2007 #1Just Joined!
- Join Date
- Feb 2007
- Posts
- 18
Split the name to 2 parts
Hi All,
Could you please help me out here!
Issues:
I have the file name like A4LNEU__20061123. I would like like the split the name of the file to 2 parts. Each part should have only 4 characters.
like:
Part1:A4LN
Part2:EU__
I need to redirect the out put to one more file.
Please help me out to resolve this issue.
Many Thanks,
Vishnu.
- 05-30-2007 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
eg in bash interaction
Code:# var=A4LNEU__20061123 # var1=$(expr "$var" : '\(.*__\)') # echo $var1 A4LNEU__ # lenvar1=${#var1} # lenvar1half=$((${#var1}/2)) #depending on whether you know the length # first=${var1:0:$lenvar1half} # second=${var1:$lenvar1half} # echo $first $second A4LN EU__
- 05-30-2007 #3Just Joined!
- Join Date
- Feb 2007
- Posts
- 18
Thanks a lot for your help !! Its working fine
Kind Regards,
Vishnu.
- 06-01-2007 #4Just Joined!
- Join Date
- Jun 2007
- Posts
- 4
Can also do this in one line:
echo A4LNEU__20061123 | sed -r 's/^(....)(....).*$/\1\n\2/'
You can then redirect result into a file using '>' redirection.


Reply With Quote