Search code examples
grepcut

cut bunch of words from text file


i am trying to get a last part from 800 lines and saving it into a new file using bash :

example

framework/resources/Functional/tpcds/variants/json/q3_1.sql
metastore/scripts/upgrade/derby/hive-schema-1.3.0.derby.sql
coeus-db/coeus-db-sql/src/main/resources/co/kuali/coeus/data/migration/sql/mysql/rice_server/bootstrap/V400_002__KR_RICE_01_1.0.3.2-2.0.0_2010-04-15_B000.sql
sql/Updates/0.0.3/r1358_mangos.sql
coeus-db/coeus-db-sql/src/main/resources/co/kuali/coeus/data/migration/sql/mysql/kc/bootstrap/V521_047__KC_DML_01_KRACOEUS-7036_B000.sql
src/FrontEnd/db/1.x/1.1/src/02.functions-and-logic/office/office.get_office_name_by_id.sql

I want the output to be like

q3_1.sql
hive-schema-1.3.0.derby.sql
V521_047__KC_DML_01_KRACOEUS-7036_B000.sql
V400_002__KR_RICE_01_1.0.3.2-2.0.0_2010-04-15_B000.sql
V521_047__KC_DML_01_KRACOEUS-7036_B000.sql
office.get_office_name_by_id.sql

Can someone please tell me how do i achieve it using cut/grep command?


Solution

  • I suggest using the following AWK command instead: awk 'BEGIN{FS = "/"} {print $NF}'