mechanicus01
asked on
Remove First Word From Each Line in File
Hello
I need a shell script to remove the first word from each line in a text file.
The file looks like this:
I am looking to remove the KERB5_TAG-43 and KERB5_TAG.
I need a shell script to remove the first word from each line in a text file.
The file looks like this:
KERB5_TAG-43 KERB5 SET REALM ""
KERB5_TAG KERB5 SET SRVTAB ""
I am looking to remove the KERB5_TAG-43 and KERB5_TAG.
ASKER
Some of the lines have a "-" followed by a number.
Ex:
Ex:
LDAP-TAG-92
LDAP-TAG-93
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sed "s/^[A-Za-z0-9_-]*//" filename
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, thanks...Let me figure out how to distribute the points.
@farzani: cut will work just fine, as the OP says: "The file looks like this" - no way telling that the your sed pattern A-Za-z0-9_- will work in all cases.
Both cut and sed work perfectly for the sample given. awk would be more flexible in recognizing whitespace, tabs etc. We could ask for more details about the source file instead of making assumpitons ;)
Both cut and sed work perfectly for the sample given. awk would be more flexible in recognizing whitespace, tabs etc. We could ask for more details about the source file instead of making assumpitons ;)
ASKER
Thanks.. they all worked but the cleanest using cut. Sed with regex worked but not all lines..
Use -i if you want to make changes to the file