Xargs seems not to pass some files.
Bash script purpose : Add a ‘.sh’ extension if missing.
I feed a temporary file from find command.
find “$CURRENT_SRC” -type f ! -name “pl” -exec bash -c ‘head -n1
“$1” | grep -q “^#![[:blank:]]/bin/bash”‘ _ {} ; -print | tee -a
“$OUTPUT_LOG”cat "$OUTPUT_LOG" | sort > "$OUTPUT_LOG_SORTED"
The result is a list of 186 files like :
…. …. …./SBin/hardware_graphical_subsystem_driver_in_use
…./SBin/hardware_graphical_subsystem_info
…./SBin/hardware_graphical_subsystem_info_to_file
…./SBin/hardware_graphic_nvidia_remove_driver_procedure_part1.sh
…./SBin/hardware_graphic_nvidia_remove_driver_procedure_part2.sh
…./SBin/hi …./SBin/hmac_md5_launcher
…./SBin/kde_config_change_kactivity_index_in_database_launcher.sh
…./SBin/kde_config_change_kactivity_index_in_database.sh
…./SBin/net_network_avahi-browse
…./Sbin/net_network_configure_network_device_card …. ….
The temporary files is red and each filename is pushed to a function using xargs
cat “$OUTPUT_LOG_SORTED” | xargs -L 1 bash -c ‘make_input_output “$@”
“$CURRENT_DEST” “$CURRENT_BACKUP_DEST” ‘ _
The purpose of the funtion ‘make_input_output’ is to add a ‘.sh’ extension if none exists on the current file else just return the current file..
When finished all files have a ‘.sh’ extension.
The problem :
The four files in the list which have already a ‘.sh’ extension are not passed to the function.
If I replace the calling sequence by :
cat “$OUTPUT_LOG_SORTED” | xargs -L 1 bash -c ‘echo “$@” —
“$CURRENT_DEST” — “$CURRENT_BACKUP_DEST” ‘ _
I got all the files.
….
….
….
…./SBin/hardware_graphical_subsystem_info — …./SBin — …./SBin
…./SBin/hardware_graphical_subsystem_info_to_file — …./SBin — …./SBin
…./SBin/hardware_graphic_nvidia_remove_driver_procedure_part1.sh — …./SBin — …./SBin
…./SBin/hardware_graphic_nvidia_remove_driver_procedure_part2.sh — …./SBin — …./SBin
…./SBin/hi — …./SBin — …./SBin
…./SBin/hmac_md5_launcher — …./SBin — …./SBin
…./SBin/kde_config_change_kactivity_index_in_database_launcher.sh — …./SBin — …./SBin
…./SBin/kde_config_change_kactivity_index_in_database.sh — …./SBin — …./SBin
…./SBin/net_network_avahi-browse — …./SBin — …./SBin
…./SBin/net_network_configure_network_device_card — …./SBin — …./SBin
…./SBin/net_network_eth_initial_config — …./SBin — …./SBin
….
….
….
I do not understand where the problem come from.
Any help is welcome.